extracting username

Forgive my ignorance ya'll. I'm trying to extract a username from a table using the user id.

I've tried: @authenticated_user = User.find(:first, :select => "login", :conditions => "id = '1'") AND: @authenticated_user = User.find_by_sql("select login from users where id='1'")

within an action that corresponds to a view that has <%= @authenticated_user %>, and all I get for output is:

If you look at the html page source, you'll find that the output is actually #<User:0x0290483> - the browser does not display the <...> stuff.

What the ActiveRecord find method returns you if you give it a select statement explicitly is an object instance of the model class, with the fields in the select statement. So @authenticated_user.login will work.

I don't see a reason though why you can't pull the whole user out of the database - why do you only want the login field? There's a lot more typing involved, which means it's almost certainly wrong :wink:

Cheers, Max