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

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| %>

<%= f.file_field :image_file %>


<%= f.submit ‘Upload’ %>


<% 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

So, I had an extra end in the method above my update method in the
controller, lol silly error

Jennifer

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs