Reputation: 7893
I have added created new migration:
class AddColumnsToDiscipline < ActiveRecord::Migration
def change
add_column :disciplines, :days, :integer, array: true
end
end
Then I have run migration.
In my seed.rb
file I have added this
t.disciplines.create(name: Company.name, days: [1, 2, 3])
After when I run rake db:seed
, When I run my rails console
all created models days
attribute has nil
value. Whad did I miss?
Upvotes: 5
Views: 10317
Reputation: 2575
try this with default
option
add_column :disciplines, :days, :integer, array: true, default: []
in your migration file and then
run rake db:seed
EDIT
Try as
add_column :disciplines, :days, :integer, array: true, default: '{}'
and change create
to create!
t.disciplines.create!(name: Company.name, days: [1, 2, 3])
If you are using strong parameters
have you permitted days
in your controller
Upvotes: 7