undefined method `relation’ for nil:NilClass on Heroku

I host almost 100% of my open source projects on Heroku, it’s amazing how easy it is to setup and how “out-of-your-way” they are.

Today, while working on one of my open source project I encountered this error:

plan.update_attributes!({:contract_id_with_trial => 2133290})
NoMethodError: undefined method `relation' for nil:NilClass
/app/.bundle/gems/ruby/1.9.1/gems/arel-2.0.9/lib/arel/crud.rb:12:in `update'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/persistence.rb:255:in `update'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/locking/optimistic.rb:77:in `update'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:68:in `update'
view raw heroku_error This Gist brought to you by GitHub.

It was right after I deployed and migrated the database.

After about 5 minutes of head scratching I came across an answer on stackoverflow saying you have to restart your app after a migration for it to pick up on schema changes.

Had a DAH! moment there :-)

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com