Victor Lam
Victor Lam

Reputation: 3710

How to call a method in ApplicationController?

I have a method defined in ApplicationController:

def some_checking
  ...
end

And I would like to call it from within another controller. E.g.:

class OtherController < ApplicationController

  some_checking

  def xxx
  end

end

How can I accomplish this? I just can't get into some_checking.

Upvotes: 0

Views: 1036

Answers (1)

Fran
Fran

Reputation: 1073

I'm not quite sure on what you want to do. If I've understood you've defined a method on ApplicationController and you want it to be called inside OtherController. To do this you can both use before_filter or just call the method from inside the xxx method itself.

Take a look to available filters here http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html

Upvotes: 3

Related Questions