Rails / cancan环境:
可能是一个愚蠢/简单的问题,但是如何将can / can中的任意文本记录到当前环境的相应日志文件中(p.ex。log/development.log
)?
我们假设:
foo
MyObject
models/ability.rb
看起来像这样class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user (not logged in) if user.admin? can :manage, :all else Rails.logger.debug "outside" can :foo, MyObject do |myobj| Rails.logger.debug "inside" true end end end end
为什么Rails.logger.debug "outside"
打印到log/development.log
但Rails.logger.debug "inside"
不是,虽然foo
内的controllers/myobjects_controller.rb
被调用(记录调试文本当然有用) )?