Request: Can we make so I can say :controller => FooController (in addition to) :controller => ''foo''? David
On Jul 10, 2005, at 4:39 AM, David Corbin wrote:> Request: Can we make so I can say :controller => FooController (in > addition > to) :controller => ''foo''?Slip this at the end of your config/environment.rb: class ActionController::Base class << self alias_method :to_param, :controller_path end end This opens the base controller class'' singleton class and aliases the existing controller_path method to to_param, suitable for use in url_for. Please post an enhancement request at http://dev.rubyonrails.com/ newticket jeremy
Jeremy Kemper wrote:> > Slip this at the end of your config/environment.rb: > > class ActionController::Base > class << self > alias_method :to_param, :controller_path > end > end >Actually you might want to do class AC::Base class << self def to_param() ''/'' + controller_path end end end so that it works properly when you''re in nested controllers. Assuming you use nested controllers. Does anyone use those? In retrospect I would like to remove the assumed nesting, so if you wanted admin/user, you would have to say :controller => ''admin/user'' no matter where the current controller is. Perhaps for Rails 2.0...