Can't upload images - probably cause my routes are messed up

0 views
Skip to first unread message

Jennifer Lee

unread,
Jul 27, 2010, 3:57:08 PM7/27/10
to rubyonra...@googlegroups.com
I am attempting to create a model called "encyclopaedia" with multiple
sections of encyclopaedia articles, each section having an image.

When I attempt to upload an image, I get the error:

Unknown action

No action responded to upload. Actions: create, destroy, edit,
get_encyclopaedia, index, is_admin?, is_owner_of, new, show, and update

I have the upload method in my sections controller and I call it from my
view with:

<% form_for [@encyclopaedia,@section], :url =>{:controller => :sections,
:action => :upload },:html => { :multipart => true, :method => 'put'} do
|f| %>
<p><%= f.file_field :image_file %></p>
<p><%= f.submit 'Upload' %></p>
<% end %>

in my routes.rb file, I have set up a nested route to access the upload
method:

map.resources :encyclopaedias do |encyclopaedias|
encyclopaedias.resources :sections,
:member => { :upload => :put}
end

and rake routes outputs:

upload_encyclopaedia_section PUT
/encyclopaedias/:encyclopaedia_id/sections/:id/upload(.:format)
{:action=>"upload", :controller=>"sections"}

This seems to be what I want, but I'm fairly new to rails so I'm
probably missing something...

Does anyone know why I can't use the upload method in my controller?

Thanks,

Jennifer
--
Posted via http://www.ruby-forum.com/.

Jennifer Lee

unread,
Jul 27, 2010, 4:55:39 PM7/27/10
to rubyonra...@googlegroups.com
So, I had an extra end in the method above my update method in the
controller, lol silly error
Reply all
Reply to author
Forward
0 new messages