Topic: Accessing attribute through association
I'm learning Rails and wondering if there is a better way to do the following:
I have 2 tables, "Users" and "Profiles".
A user has one profile and a profile belongs to one user.
I am trying to access data in the profile table from the user controller.
@history = Profile.where(user_id: current_user.id) works, but I'm wondering if there is another way?
Specifically, in a 1:1 relationship doesn't the attribute in the profile table become an attribute of the user table so something like
@history = current_user.profile.last_subject_id is more like what I would have expected.
Last edited by dcastellano1 (2013-03-11 16:03:31)