【发布时间】:2011-07-06 20:33:06
【问题描述】:
我以为我们会这样做
helper_method :current_user, :logged_in?, :authorized?
使这些控制器方法可用作视图中的辅助方法。但是在 Restful Authentication 的 lib/authenticated_system.rb 中,我看到了:
# Inclusion hook to make #current_user and #logged_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :logged_in?, :authorized? if base.respond_to? :helper_method
end
为什么用这种方式而不是单行?另外,我没有看到 included 在任何地方被调用。
【问题讨论】:
标签: ruby-on-rails restful-authentication