繁体   English   中英

如何在ApplicationController中调用方法?

[英]How to call a method in ApplicationController?

我有一个在ApplicationController定义的方法:

def some_checking
  ...
end

我想从另一个控制器中调用它。 例如:

class OtherController < ApplicationController

  some_checking

  def xxx
  end

end

我该怎么做? 我只是无法进入some_checking

我不太确定你想做什么。 如果我了解您已经在ApplicationController上定义了一个方法,并且希望在OtherController中调用它。 为此,您都可以使用before_filter或只从xxx方法本身内部调用该方法。

在此处查看可用的过滤器http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM