views:

60

answers:

1

Inside a given controller "BobsController" - is the controller argument on the redirect_to method optional, so that:

redirect_to(:controller => 'bobs', :action => 'index')

is the same as:

redirect_to :action => 'index'

when being used inside the BobsController class? I assume because the controller is derived from the current controller?

+4  A: 

Yes you're correct. It assumes the current controller if :controller is not provided.

bensie
Thanks so much (now to remove a whole bunch of redundant code from my controllers).
Ash
If you're using RESTful Rails resources, you can also use the easier named routes generated by the router: map.resources :bobs would give you the ability to do redirect_to bobs_path....
bensie
Oh cool! I didn't know that, cheers.
Ash