3

I am running rails 4.0.4 with ruby 2.1.1. app location: https://github.com/ravjohal/dozmia

When I try to run commands on heroku, for instance:

ravjohal$ heroku run rake db:migrate

I get the following error:

Running `rake db:migrate` attached to terminal... up, run.2545
rake aborted!
NoMethodError: undefined method `dump_schema_after_migration=' for ActiveRecord::Base:Class
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/railtie.rb:166:in `block (3 levels) in <class:Railtie>'...../app/config/environment.rb:5:in `<top (required)>'....

here is part of the heroku logs:

/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `dump_schema_after_migration=' for #<Class:0x007fa6e13d76d0> (NoMethodError)
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
2014-03-27T18:30:55.730401+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:464:in `each'
2014-03-27T18:30:55.730191+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
2014-03-27T18:30:55.730191+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/railtie.rb:165:in `block (2 levels) in <class:Railtie>'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
2014-03-27T18:30:55.729964+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/railtie.rb:165:in `each'
2014-03-27T18:30:55.730191+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `b
lock in require'
2014-03-27T18:30:55.730191+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.4/lib/active_record/base.rb:22:in `<top (required)>'
2014-03-27T18:30:55.730191+00:00 app[web.1]:    from /app/app/models/playlist.rb:1:in `<top (required)>'

I had deployed my app using 4.1.0rc1 Rails (worked fine) and then changed the Gemfile to use 4.0.4 instead. I also changed my local development database to pg instead of sqllite3. Those are the only two changes I have made and only after those changes did the issue appear on heroku. App works great on localhost.

EDIT: I also want to add that I changed the app name locally (not sure if that would matter though).

Rav Johal
  • 374
  • 2
  • 14
  • Have you ran bundle `update` / `install` after changing the GemFile? – Richard Peck Mar 28 '14 at 10:27
  • I suspect the issue is your version of Rails has a bug, and consequently causing problems with your system. If you've just changed the GemFile reference to the Rails gem, you may wish to bundle the app again – Richard Peck Mar 28 '14 at 10:28
  • 1
    I have bundled it after changing the rails version to no avail. – Rav Johal Mar 28 '14 at 14:35

3 Answers3

9

So after trying many things, and hitting myself on the head for NOT trying something obvious...I removed the following line from environments/production.rb file:

config.active_record.dump_schema_after_migration = false

It worked fine on heroku thereafter.

Rav Johal
  • 374
  • 2
  • 14
  • This works (on rails 4.1.9 on Heroku) but I do not understand why removing a configuration option that explicitly states " DO NOT to do the thing that is causing an error" fixes the issue. – Ivar Mar 17 '15 at 23:56
7

The config dump_schema_after_migration didn't exist in Rails 4.0.4 .

You got the error because you deployed initially with Rails v4.1.0rc1 and switched over to v4.0.4 later. What really happened is that when you generated your app with rails 4.1.0rc, the generator put the config dump_schema_after_migration into your config/environments/production.rb and Rails 4.1.0rc1's code has this to support this config :

mattr_accessor :dump_schema_after_migration

Hence everything works fine in v4.1.0rc1. But when you moved back to v4.0.4, the config is still there in config/environments/production.rb , but the Rails code no longer knows how to read this config. To solve this, either stick with Rails 4.1.0rc1 code, or remove the config from config/environments/production.rb when running on Rails 4.0.4.

Btw, I added dump_schema_after_migration config to Rails code.

Emil
  • 1,240
  • 1
  • 15
  • 27
0

I don't have an answer, but a reason why the issue will be happening

When using a beta version of a product (Rails), you'll get a lot of new (relatively untested) functionality. This will work, but may cause issues with earlier versions of the software, as new generally means more functionality etc

If you're starting with Rails, I would recommend removing the Rails 4.1.0 gem from your system: gem uninstall rails, and then installing Rails 4.0.4 again - gem install rails

It's going to be an issue with Rails 4.1.0, but I'd need to experiment a little

Richard Peck
  • 76,116
  • 9
  • 93
  • 147