I have added a column to my table via a migration, but I am not able to access the added column in the subsequent migration file.
When I execute rake db:migrate
the migration aborts, but when I execute it again the migration succeeds, not sure what I am doing wrong. Any help would be appreciated. Thanks.
below is the code where i am adding column
**
class AddIsDispatchToUsers < ActiveRecord::Migration
def change
add_column :users, :is_dispatch, :boolean, :default=>false
end
end
**
Now, when i try to access the column in next migration file it fails.
The subsequent migration file has the code below
service_member = Member.create(:is_dispatch=>true)
And Here is the error that it produces
unknown attribute: is_dispatch/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1764:in `block in assign_attributes'
/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1758:in `each'
/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1758:in `assign_attributes'
/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1578:in `initialize'
/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:508:in `new'
/Users//.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:508:in `create'
/Users//Desktop/RailsDevelopement//db/migrate/20161003121452_add_dispatch_services.rb:11:in `up'
Have you tried User.reset_column_information
after add_column
in same migration.