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