Simple noob question about rails data access

Hi Max,

Max Williams wrote:

I have an 'article' object which has a foreign key to a 'user', linked
by 'user_id'. My current article on a view page is called @article.
What i need to do is to get the 'login' attribute of the user with the
same id as @article 's user_id.

Ie - if i know a user id, how do i get the user object with that id?

Assuming that your User model has_many :articles, and your Article model belongs_to :user, you can access that attribute in your view with:

@article.user.login

HTH,
Bill