Rails has standardization to popularize your database, this standardization serves to maintain the maintenance of your app. I do not know how the columns in your database are, so I'll post a generic template:
Within the folder of your Rails project, you will have the following file: db/seed.rb
, this is the file responsible for popularizing your database.
You can enter data as follows:
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
##
Departament.create(name: 'Poltronas', subtitle:'', slug: 'poltronas', description: '')
Departament.create(name: 'Puffs', subtitle:'', slug: 'puffs', description: '')
Departament.create(name: 'Sofás', subtitle:'', slug: 'sofas', description: '')
Departament.create(name: 'Chaises', subtitle:'', slug: 'chaises', description: '')
Departament.create(name: 'Banquetas', subtitle:'', slug: 'banquetas', description: '')
Departament.create(name: 'Office', subtitle:'', slug: 'office', description: '')
Departament.create(name: 'Cadeiras', subtitle:'', slug: 'cadeiras', description: '')
Departament.create(name: 'Mesas', subtitle:'', slug: 'mesas', description: '')
Departament.create(name: 'Itens', subtitle:'', slug: 'itens', description: '')
Departament.create(name: 'Pronta Entrega', subtitle:'', slug: 'pronta-entrega', description: 'Conheça nossos produtos disponíveis a pronta entrega')
You can also use iterations in the same example:
5.times do |i|
Product.create(name: "Product ##{i}", description: "A product.")
end
To apply your popularization simply enter your terminal in the folder of your project with the command:
rake db:seed
There are people who include these popularizations in Migrations
also ...
class AddInitialProducts < ActiveRecord::Migration
def up
5.times do |i|
Product.create(name: "Product ##{i}", description: "A product.")
end
end
def down
Product.delete_all
end
end