开发者

How to call a method in ApplicationController?

开发者 https://www.devze.com 2022-12-27 00:47 出处:网络
I have a method defined in ApplicationController: def some_checking ... end And I would like to call it from within another controller. E.g.:

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_chec开发者_Python百科king

  def xxx
  end

end

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消