I have an action in a controller that I need to make available to
other controllers and views.
I put the action in ApplicationController and ApplicationHelper but it
didn’t work.
Thank you for any help.
I have an action in a controller that I need to make available to
other controllers and views.
I put the action in ApplicationController and ApplicationHelper but it
didn’t work.
Thank you for any help.
Jose Hales-Garcia wrote:
I have an action in a controller that I need to make available to
other controllers and views.I put the action in ApplicationController and ApplicationHelper but it
didn’t work.Thank you for any help.
ApplicationHelper houses methods for your views and not actions. If you
want actions to be shared by multiple controllers there are 2 ways of
doing this
domain specific controllers .so it will look something like this
class CommonController < ApplicationController
def common_action
end
end
class Domain1Controller < CommonController
end
…
class Domain2Controller < CommonController
end
Now whenever you call common_action in either domains they will be
available for execution so url will like this
http://…/domain1/common_action
http://…/domain2/common_action
Hope this helps
-Rajesh
At 11:41 AM 2/7/2007, you wrote:
I have an action in a controller that I need to make available to
other controllers and views.I put the action in ApplicationController and ApplicationHelper but it
didn’t work.
Try putting the shared code into a module and mixing it in. It worked
for me.
-Kathy Van Stone
[email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs