Skip to content

Instantly share code, notes, and snippets.

@itsNikolay
Created February 7, 2013 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsNikolay/4729133 to your computer and use it in GitHub Desktop.
Save itsNikolay/4729133 to your computer and use it in GitHub Desktop.
model
$> rake g migraiton add_institution_id_to_users institution_id:integer
$> rake g migration add_user_id_to_loans user_id:integer
$> rake g migration add_loan_id_to_quotes loan_id:integer
$> rake g migration add_institution_id_to_type_of_loans institution_id:integer
models/institutions.rb
class Institution < ActiveRecord::Base
has_many :users
has_many :type_of_loans
end
models/user.rb
class User < ActiveRecord::Base
has_many :loans
belongs_to :institution
end
models/loan.rb
class Loan < ActiveRecord::Base
has_many :quotes
belongs_to :user
end
model/quote.rb
class Quote < ActiveRecord::Base
belongs_to :loan
end
model/type_of_loan.rb
class TypeOfLoan < ActiveRecord::Base
has_many :loans
belongs_to :institution
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment