Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

NoMethodError: undefined method `result' for #< NoMethodError: ...>

Stack trace refers to this place:

def current_income
  return @current_income if defined? @current_income
  if session[:income_id] && session[:income_id] != nil
    @current_income ||= Income.find session[:income_id] # Line 13 - error place
  else
    create_current_income # Creates new income method
  end
  return @current_income
end

This error is only in production model on heroku. My configuration:

  • Ruby 2.0.0 + Rails 3.2.13
  • Unicorn server + Postgresql 9.3

At beginning it seems there was problem with Threads and Postgresql connections, but I already did all forking staff for ActiveRecord:

# config/unicorn.rb

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)
preload_app true

before_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end  

after_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

Did someone has had similar issue who can help me with tip?

share

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.