I’m using Ruby on Rails 3.0.7 and MySQL 5.1. I’d like to force to store the object id in a migration file. For example I have this:
User.create!(
:name => 'Test name'
)
but I would like to do something like this:
User.create!(
:id => '12345', # Force to store the object data with id '12345'
:name => 'Test name'
)
Note: the above code will not force the id value in the database.
Is it possible? If so, how?
You can’t mass assign the restricted fields like
id. But you can individually set them:OR