18 May 2011, 23:22

William Hertling (23 posts)

Can anyone get the file uploading example to work? In Rails In Depth, Action View, Uploading Files to Rails Applications (starts at p.345). I can’t seem to get it to work. I’m getting routing errors. The example given doesn’t tell us what, if any, routes need to be defined.

First it complained that index wasn’t defined. I redefined the get method on the controller to index. Then it complains that the save route isn’t defined: No route matches {:action=>”save”, :controller=>”upload”}

I tried adding this to routes.rb:

resources :upload do get :get get :save end

But still no luck. save is defined in my UploadController. What else do I need to do to get this to work?

24 May 2011, 14:08

Dave Bishop (1 post)

I’ve got the same problem - routing - specifically;

No route matches {:controller=>”upload”, :action=>”save”}

Any help or an expanded step by step on uploading and displaying pictures would be great.

11 Aug 2012, 18:17

OTA (3 posts)

Any luck on getting this to work? Help will be very much appreciated!

11 Aug 2012, 20:16

OTA (3 posts)

I got this working as follows:

  1. route file:

resource :upload do get :get post :save get :show end

  1. had to rename the “upload_controller.rb” to “uploads_controller.rb”

  2. Had to rename the views directory from “upload” to “uploads”

  3. Had to change the first line of the get.html.erb to include an equal sign: <%= form_for(:picture…

Hope this works for you as well.

02 Oct 2012, 06:10

Celso de Sá Lopes (1 post)

The above was very useful. But I found a much easier solution:

1- on line_items_controller, change:

2- @line_item = @cart.line_items.build to @line_item = @cart.line_items.build(:product_id => product.id)

22 Jan 2013, 15:42

Venkat K (1 post)

It still does not work. I get a MassAssignmentSecurity error in uploadscontroller save action.

Does anybody or the authors of the book have any suggestions?

  You must be logged in to comment