In my application I have an accounts model:
class Account < ActiveRecord::Base belongs_to :user has_many :invoices end
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) end end
Invoices can then be assigned to one of these initial accounts:
class Invoice < ActiveRecord::Base belongs_to :accounts end
Is this the proper way to to create the default accounts?