EastsideDev
EastsideDev

Reputation: 6639

logger.info is not working in a Rails model

Rails 3.2

I've used logger.info successfully in the past. Today, I was trying to debug a model's action, and it's breaking my application. My code (in 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

Here's the error message:

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'

Line 40 is:

logger.info("File: #{__FILE__ } -- LINE: #{__LINE__ }")

Any ideas?

Upvotes: 1

Views: 72

Answers (1)

smathy
smathy

Reputation: 27961

Call logger on the Rails constant: Rails.logger.info

Upvotes: 1

Related Questions