Edited by:
The rake db:seed command basically executes any code that you write in your application's db/seeds.rb file. Although you can write any code in this file, by convention you should write code that populates the database with basic data,
for example: when you ever deploy your application and create a new database for it, you want this user with administrator credentials to be present there. Thus, you will write the code that will create this user in this file. The following is sample code that will create the user and assign him the administrator role.
puts "********Seeding Data Start************" admin = User.create(:first_name => 'System', :last_name => 'Admin', :email => ' systemadmin@sunpower.com ', :password => 'sunpoweradmin', :password_confirmation => 'sunpoweradmin', :source_system_id => 'systemadmin', :source_system => 'LP',:entity_type => "Customer", :target_system => "OPENAM") if admin.errors.blank? puts "***User #{admin.first_name} #{admin.last_name} created ***" admin.add_role :admin
Now, when you recreate your database, you just need to run the command below to populate the database, with basic data
$ rake db:seed RAILS_ENV=production
The correct database installation procedure during production, with the entire rake task available in the db namespace below
$rake db:create RAILS_ENV=production $rake db:migrate RAILS_ENV=production $ rake db:seed RAILS_ENV=production
NOTE. . You can replace the first two commands with $rake db:setup RAILS_ENV=production , it will be run both for creation and for migration inside
OR
You can use rails-settings-cached gem , which is the fork of the rails settings graph
After setting up, you can do things like:
Setting.foo = 123 Setting.foo # returns 123
Hope this helps you or what you are looking for.