In my application I have an accounts model:
class Account < 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 < 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?
"Foo"
and"Bar"
? We don't like it when foo/bar appear in Code Review questions, because it's a sure sign that you're hiding some information from us. \$\endgroup\$