Rails 3.2
我过去已成功使用logger.info。今天,我试图调试模型的动作,这破坏了我的应用程序。我的代码(在models / admin_ability.rb中):
can :decline, Ticket do |ticket|
if ticket.persisted?
logger.info("File: #{__FILE__ } -- LINE: #{__LINE__ }")
executor = ticket.executor
ticket_profile = ticket.ticket_profile
decliners = ticket.decliners
suitable_companies = ''
suitable_companies = ticket_profile.suitable_companies(decliners, ticket.customer, ticket.customer_info.zip, ticket.requested_date_start,
false, false) if decliners.blank?
suitable_companies.delete(ticket.executor)
!(suitable_companies.compact).blank?
end
end
这是错误消息:
undefined local variable or method `logger' for #<AdminAbility:0x007f8382bfd3f0>
Rails.root: /home/app
Application Trace | Framework Trace | Full Trace
app/models/admin_ability.rb:40:in `block in initialize'
第40行是:
logger.info("File: #{__FILE__ } -- LINE: #{__LINE__ }")
有什么想法吗?
答案 0 :(得分:1)
在logger
常量上调用Rails
:Rails.logger.info