Since all controllers are inherited from ApplicationController,
methods of ApplicetionController are only inherited as "methods" and
not as "actions". You can use these inherited methods like normal
methods, but you can not use them as "actions" (i.e., methods that are
executed upon a request via routing).

Requiring the same action for multiple controllers is quite uncommon,
there may be better methods to do the same thing.
But still you can use this -

class ApplicationController < ActionController::Base
 def common_action
   #code
 end
end

class ExampleController < ApplicationController

  def common_action
    super
    #render 'shared/common_action' #uncomment this line if you want to
use a common template too.
  end
end

On Jul 27, 6:38 am, doug <[email protected]> wrote:
> I reasoned that placing an action in the application controller would
> be roughly equivalent to placing that action in each of the other
> controllers since each of the other controllers inherits from the
> application controller.  It turns out that that doesn't work.  It
> behaves as if the action is missing from the other controllers.  I
> thinking that, for whatever reason, when Rails looks for an action it
> only looks at the controller and doesn't look up the chain. If the
> action isn't there, it behaves accordingly.  Can anyone tell me why
> that is and what I should do about it if I want the action in the
> application controller to be available in several other controllers?
>
> Thanks for any input.
>
>         ... doug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to