ruby on rails 3 - Can "belongs_to" be defined more than once in Active_Record? -
i trying write database company in town. using devise authentication, , forem forums of site. decided have 1 class, "account" devise authentication, have many different access types site.
the bulk of users customers, segregated routes (not rails routes, street routes). decided have them have own profile model.
i want - profile linked account, , route. (routes named gmr_routes)
is code proper way it? documentation i've found hasn't told me can't, want sure....
class profile < activerecord::base attr_accessible :first_name, :last_name, :phone_number, :street_address belongs_to :account belongs_to :gmr_route end
account has has_one relationship profile, , gmr_route has has_many.
is right?
bryan
yes, that's acceptable. need remember include foreign key id on model belongs_to.
so in case describe, have account_id:integer
, gmr_route_id:integer
in migration, , include in attr_accessible
call in model
Comments
Post a Comment