Rails Throws Error When Using redirect_to :back

redirectruby-on-railsundefined

Whenever I use:

redirect_to :back

in my Rails controllers, I get the following error:

undefined method `object_url' for SubmissionController:0xb7a37764

I'll paste the application trace below as well:

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
__send__'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
polymorphic_url'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:628:in
url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1085:in
redirect_to'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1080:in
`redirect_to'

app/controllers/submission_controller.rb:38:in
`show'

I'm pretty sure its not a syntax error, but something deeper. Maybe a problem occurred during an update or something. Any thoughts would be greatly appreciated!

Thanks for looking.

Best Answer

I don't think you should be using "redirect_to" in this case, just use ":back". For example:

is shorthand for the JavaScript utility obtaining the previous URL in your history.

Related Topic