Hi all,
Can I use code from one controller in another controller? If so, how do i do this?
Thanks Stijn
Hi all,
Can I use code from one controller in another controller? If so, how do i do this?
Thanks Stijn
You don't. You extract the common code into a third piece. Either an object that is instantiated in each of the controllers or a mixin module that is included in each.
Michael
Thanks for the reply,
Where in my rails structure do I put this common code directory wise? Somewhere in the app director?
Is there some tutorial on this?
Stijn
Where in my rails structure do I put this common code directory wise?
Somewhere in the app director?
Is there some tutorial on this?
http://www.robbyonrails.com/articles/2007/02/09/extending-actioncontroller-part-two
-ed
You can.
class ApplicationController < ActionController::Base helper_method :current_user, :logged_in? end
This will make the 'current_user' and 'logged_in?' controller methods available to all views.