简体   繁体   中英

Production mode: what is “the best way”\“the most commonly used approach” to change and add data in database?

I am using Ruby on Rails v3.0.9 and I have a web application running in production mode. I would like to change and add some data in the database (also, I would like to make that these data changes take effect in development mode - that is, for example, that the added data should be present also in development mode when I am running and developing my application on my local machine )...

... what is "the best way"\\"the most commonly used approach" to do that? I mean, for example, should I create a migration file with in some User.create(:name => '...', :surname => '...', ...) statements and run those or there are other ways to accomplish what I would like to do?

Note : I do not need to populate the database with initial data (I already made that in the seed.rb file). I just need to update and add database table rows.

seed.rb should be use only for initial set of values.

rake task should be use only when you want to update data any existing columns.

migration should be use when you need to change the schema of the table.

You should use the file db/seed.rb to accomplish this task

Here is an example on how to use it: http://asciicasts.com/episodes/179-seed-data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM