Rails create create default database records In my application I have an accounts model:

class Account &lt; ActiveRecord::Base
  belongs_to :user
  has_many :invoices
end


The Account model belongs to the User model. After the user is created, some default accounts must be created:

class User &lt; ActiveRecord::Base
  has_many :accounts

  after_create do
    Account.create(name: "Repairs",user: self)
    Account.create(name: "Supplies", user: self)
  end
end


Invoices can then be assigned to one of these initial accounts:

class Invoice &lt; ActiveRecord::Base
  belongs_to :accounts
end


Is this the proper way to to create the default accounts?
Yeah! you are on right path but we can improve it like :

class User &lt; ActiveRecord::Base
  has_many :accounts

  after_save do
    self.accounts.create([{name: "Repairs"}, {name: "Supplies"}])
  end
end


Hopefully! This will help.