I want to prefill my table with the seeds.rb file in app/db
but there I got a problem during storing the right data.
in the table users I have an column called active withe datatype tinyint. so now I want to store with the seeds.rb int values
User.create([ { :id => 1, :firstname => 'Felix', :lastname => 'Hohlwegler', :active => 1}])
but it dosn't store 1. It always stores 0 in database.
also tried this:
User.create([ { :id => 1, :firstname => 'Felix', :lastname => 'Hohlwegler', :active => true}])
same problem it stores 0 in db.
Whats going wrong?
The most common thing that causes this kind of problems are validations. In this case I would expect that a user needs an email or a password. Please check if
passes the validations and creates an user.
Please note that I use
create!
that would raise an error if it not able to create an user instead of just returning an unsaved one.solution that works fine for me: