In my application I have an accounts model:class Account < ActiveRecord::Base  belongs_to :user  has_many :invoicesendThe Account model belongs to the User model. After the user is created, some default accounts must be created:class User < ActiveRecord::Base  has_many :accounts  after_create do    Account.create(name: Repairs,user: self)    Account.create(name: Supplies, user: self)  endendInvoices can then be assigned to one of these initial accounts:class Invoice < ActiveRecord::Base  belongs_to :accountsendIs this the proper way to to create the default accounts?
Rails create create default database records
ruby;ruby on rails;database
Yeah! you are on right path but we can improve it like :class User < ActiveRecord::Base  has_many :accounts  after_save do    self.accounts.create([{name: Repairs}, {name: Supplies}])  endendHopefully! This will help.