Rails UnknownAttributeError when raking - ruby-on-rails

Within seeds, I have created the following;
post = Post.create(
title: Faker::Lorem.sentence(20),
content: Faker::Lorem.paragraph,
publish: true,
administrator: administrator)
tag = Tag.create(name: Faker::Lorem.words)
post_tag = PostTag.create(post: post, tag: tag)
Then, within terminal i tried to "rake db:reset" and it is not working and showing the following error;
-- initialize_schema_migrations_table()
-> 0.0049s
rake aborted!
ActiveRecord::UnknownAttributeError: unknown attribute 'publish' for Post.
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord- 4.2.5.1/lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord- 4.2.5.1/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:35:in `each'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/core.rb:566:in `init_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/core.rb:281:in `initialize'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/inheritance.rb:61:in `new'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/inheritance.rb:61:in `new'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/persistence.rb:33:in `create'
/Users/laurenwoodhams/Desktop/PROJECT/RAILS-BLOG/-t/db/seeds.rb:13:in `<top (required)>'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `block in load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/engine.rb:547:in `load_seed'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/tasks/database_tasks.rb:250:in `load_seed'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/railties/databases.rake:183:in `block (2 levels) in <top (required)>'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
NoMethodError: undefined method `publish=' for #<Post:0x007f98d0073d00>
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activemodel-4.2.5.1/lib/active_model/attribute_methods.rb:433:in `method_missing'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:54:in `public_send'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:35:in `each'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/core.rb:566:in `init_attributes'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/core.rb:281:in `initialize'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/inheritance.rb:61:in `new'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/inheritance.rb:61:in `new'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/persistence.rb:33:in `create'
/Users/laurenwoodhams/Desktop/PROJECT/RAILS-BLOG/-t/db/seeds.rb:13:in `<top (required)>'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `block in load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/engine.rb:547:in `load_seed'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/tasks/database_tasks.rb:250:in `load_seed'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/railties/databases.rake:183:in `block (2 levels) in <top (required)>'
/Users/laurenwoodhams/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)
Could you please advise why it may be pushing this error?
Thank you

Then, within terminal i tried to "rake db:reset" . . .
Try running:
rake db:migrate
rake db:reset
Your Post object doesn't have a publish attribute according to your database (for whatever reason).
When you run rake db:reset new migrations do not get, 'migrated.' Instead it loads the schema (that will not include migrations that were not migrated).
More info: https://stackoverflow.com/a/10302357/1026898

Related

NoMethodError with Rails app deployed to Heroku (When calling .create on model)

I am writing a Ruby on Rails web application to be deployed on Heroku.
The development database is SQLite and the production database is PostgreSQL.
Everything works locally in the development and test environments, and worked on Heroku up until the last batch of revisions. Suddenly, attempting to create an instance of the Customer model is throwing
'NoMethodError undefined method `each' for nil:nilclass'.
The migrations have definitely been run, I have tried pg:reset and re-running migrations, and I have also tried restarting heroku.
If I open the rails console on heroku and try to call any of the following methods I get the same error
Customer.count
Customer.create(...)
Customer.new
Can anyone help resolve this issue?
EDIT:
Stacktrace when running rails db:migrate with Postgres DB ( no errors with SQLite )
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke db:load_config
** Execute db:schema:dump
rails aborted!
NoMethodError: undefined method `each' for nil:NilClass
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/descriptive_statistics-2.5.1/lib/descriptive_statistics/support/convert.rb:37:in `to_array'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/descriptive_statistics-2.5.1/lib/descriptive_statistics/support/convert.rb:8:in `convert'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/descriptive_statistics-2.5.1/lib/descriptive_statistics/sum.rb:3:in `sum'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/enumerable.rb:185:in `sum'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/schema_statements.rb:659:in `sequence_name_from_parts'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/schema_statements.rb:631:in `new_column_from_field'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:115:in `block in columns'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `map'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `columns'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:112:in `table'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:100:in `block in tables'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:99:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:99:in `tables'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:44:in `dump'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/schema_dumper.rb:28:in `dump'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:377:in `block in dump_schema'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:376:in `open'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:376:in `dump_schema'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:392:in `block (4 levels) in <main>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:390:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:390:in `block (3 levels) in <main>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:97:in `block (2 levels) in <main>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:88:in `block (2 levels) in <main>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/command.rb:48:in `invoke'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/commands.rb:18:in `<main>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/Users/harilimaye/Documents/CompSci/Year 2/SEG/smg/alpaca_online_banking/bin/rails:9:in `<top (required)>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
/Users/harilimaye/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
/Users/harilimaye/Documents/CompSci/Year 2/SEG/smg/alpaca_online_banking/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
So it turned out the problem was due to the inclusion of gem 'transaction_faker' in my gem-file, which added the module descriptive_statistics (the source of the problem). My GUESS is that it must override the sum method of the Enumerable module used in the conversion from migration to Postgres, or something along those lines.

Numeric conversion error with PostgreSQL and Rails

I'm getting the following error output when trying to run RAILS_ENV=production rake db:migrate on an Ubuntu instance:
/usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
And the following output as well:
/usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
/usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.6/lib/active_support/cache/strategy/local_cache.rb:138:in `local_cache_key'
/usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.6/lib/active_support/cache/strategy/local_cache.rb:74:in `middleware'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/application/bootstrap.rb:79:in `block in <module:Bootstrap>'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
/home/rails/gsc_surveying/config/environment.rb:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!'
/usr/local/rvm/gems/ruby-2.4.0/gems/railties-4.2.6/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/local/rvm/gems/ruby-2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate => environment
Switching to Ruby 2.3.1 fixed the issue.

Migration error on heroku deploy

NoMethodError: undefined method `dump_schema_after_migration=' for ActiveRecord:
:Base:Class
on
$ heroku run rake db:migrate
I am new to heroku deployment and not able to solve it, please help in solving it
Thanks in advance.
this is what I am actually getting.
$ heroku run rake db:migrate
This is the complete error trace:
Running `rake db:migrate` attached to terminal... up, run.4727
rake aborted!
NoMethodError: undefined method `dump_schema_after_migration=' for ActiveRecord:
:Base:Class
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/dynamic_
matchers.rb:22:in `method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/railtie.
rb:166:in `block (3 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/railtie.
rb:165:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/railtie.
rb:165:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/lazy_l
oad_hooks.rb:38:in `instance_eval'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/lazy_l
oad_hooks.rb:38:in `execute_hook'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/lazy_l
oad_hooks.rb:28:in `block in on_load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/lazy_l
oad_hooks.rb:27:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/lazy_l
oad_hooks.rb:27:in `on_load'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/railtie.
rb:114:in `block in <class:Railtie>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/initializable.rb:30:
in `instance_exec'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/initializable.rb:30:
in `run'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/initializable.rb:55:
in `block in run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/initializable.rb:54:
in `run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/application.rb:215:i
n `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/depend
encies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/depend
encies.rb:229:in `block in require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/depend
encies.rb:214:in `load_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/depend
encies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/application.rb:189:i
n `require_environment!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.8/lib/rails/application.rb:250:i
n `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Assuming you are using Rais 4, just remove below code in your config/environments/production.rb
config.active_record.dump_schema_after_migration = false

Can't push changes to heroku

I've added Twilio to my rails app and when I go to push the changes to heroku I'm getting the following error. I've having trouble tracing it back to the issue.
Running: rake assets:precompile
rake aborted!
undefined method `strip' for nil:NilClass
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/client.rb:142:in `initialize'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/config/initializers/twilio.rb:6:in `new'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/config/initializers/twilio.rb:6:in `<top (required)>'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:609:in `block (2 levels) in <class:Engine>'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:608:in `each'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:608:in `block in <class:Engine>'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `each'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/config/environment.rb:5:in `<top (required)>'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:250:in `block in run_tasks_blocks'
/tmp/build_04f806c2-b1ba-46f8-a554-26485f452fbd/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
Update: In my Twilio.rb (config/initializer) I had copied over some code from Twilio's site.
require "twilio-ruby"
Once I removed this I was able to get it to push to heroku.

rake db:schema:load could not find a table

EDIT from normalocity: My answer hasn't been able to solve this problem, so I'm posting a bounty for alternate solutions.
Original question:
I started to work on a Rails project a week ago, changing many times the database schema using migrations. Yesterday I try to create my database (developement environnement, default configuration) from scratch using these commands :
rake db:drop
rake db:create
rake db:schema:load
I got this message when loading the schema using --trace option :
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Could not find table 'galleries'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:439:in `table_structure'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:322:in `columns'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `yield'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `default'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `block in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `yield'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `default'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `columns_hash'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:145:in `locking_enabled?'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:110:in `to_a'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:159:in `all'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:441:in `all'
/home/fabien/Dropbox/portfolio/app/admin/photos.rb:10:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/dsl.rb:13:in `instance_eval'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/dsl.rb:13:in `run_registration_block'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/namespace.rb:171:in `parse_registration_block'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/namespace.rb:50:in `register'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:87:in `register'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin.rb:60:in `register'
/home/fabien/Dropbox/portfolio/app/admin/photos.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `block in load!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `each'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `load!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:155:in `routes'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin.rb:63:in `routes'
/home/fabien/Dropbox/portfolio/config/routes.rb:9:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:258:in `instance_exec'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:258:in `eval_block'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:235:in `draw'
/home/fabien/Dropbox/portfolio/config/routes.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `each'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `load_paths'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:13:in `reload!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:87:in `reload_routes!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:34:in `reload!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:28:in `block in initialize'
/ var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/file_update_checker.rb:32:in `call'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:45:in `block in attach!'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:404:in `_run_prepare_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/reloader.rb:46:in `prepare!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/fabien/Dropbox/portfolio/config/environment.rb:5:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:193:in `block (2 levels) in initialize_tasks'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => db:schema:load => environment
As Rails beginner, I have no idea how to solve this issue especially my schema.rb have commands to create th galleries table.
My code is available here: https://github.com/fabienengels/portfolio
You need to modify your /app/admin/photos.rb
# /app/admin/photos.rb
index :as => :grid, :columns => 6 do |photo|
Gallery.all.each do |gallery|
scope gallery.slug.to_sym do |photos|
photos.where(:gallery_id => gallery)
end
end
# link_to(image_tag(photo.file.url(:thumb)), admin_photo_path(photo))
end
you need to put that code inside the index block. I commented out your link tag there. I'll leave it up to you to figure out how to design your grid/block/whatever. just make sure it's in the index scope. Good luck.
So the issue is that when your app loads, it's loading up your activeadmin stuff. That in turn ends up running Gallery.all to know what scopes to setup.
Running a rake task like schema:load still loads the app, so it's still trying to do Gallery.all but you've just dropped/recreated the db so it's quite rightly saying that the table isn't there.
What you'd like to be able to do is tell ActiveAdmin not to bother configuring itself, as you're just running some migrations.
Luckily, there is a global variable $rails_rake_task that is set in those cases. I'd try not running the code in your active_admin initialiser whenever $rails_rake_task is true or if that doesn't work also not doing any activeadmin configuration (e.g. the stuff in app/admin/photos) if $rails_rake_task is true.
I've never used ActiveAdmin before, but from the documentation, but it seems like you can only reference a single model within an ActiveAdmin.register block, or that you simply haven't made the Gallery model visible inside of this file.
So, in app/admin/photos.rb where you have
ActiveAdmin.register Photo do
...
Gallery.all.each do |gallery| # <= this is invalid, because this file
scope gallery.slug.to_sym do |photos| # doesn't know what `Gallery` (and therefore
photos.where(:gallery_id => gallery) # `galleries` table`) is referring to
end
end
....
end
I'm not sure how to do nested ActiveAdmin registrations, or even if you can, but the error message you're getting is telling you that Gallery is not accessible within the scope of this file, and therefore, it's like, "What 'galleries table? We have no 'galleries' table here.".
So, you could try one of these two things to resolve it and see what happens - hopefully this is either the answer, or will lead you to the answer:
At the very top of the app/admin/photos.rb file, add this exact line:
require '../models/gallery'
If that doesn't work, then instead of Gallery.all.each... try
ActiveAdmin.register Gallery do followed by that same block

Resources