Forum: Ruby on Rails help with User.find() and rendering text

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sushruth B. (Guest)
on 2005-11-18 09:37
Hi all,

I'm trying to do something for a project. Herez what im trying to do.

The user name gets passes from the view to the controller.

On line2: The user name gets displayed.
On line 3: (If this command works the way I think it works, the sad part
is I always get it wrong) anyways, The entry in the data base with the
given user name gets searched and the user info gets stored in the
variable @user.
On line 4: Now how do i print it out? Is it a variable.
1. @some_variable = @params[:user_name]
2. render_text @some_variable.to_s
3. @user = User.find(:all, :conditions => [ "user_name = ?",
'@some_variable'])
4. render_text @user.to_s


I'm very sorry for this long and anoying post. I'm new to this and
really need help!

Thanks

S
alex (Guest)
on 2005-11-18 10:39
(Received via mailing list)
Sushruth blah wrote:
> variable @user.
> On line 4: Now how do i print it out? Is it a variable.
> 1. @some_variable = @params[:user_name]
> 2. render_text @some_variable.to_s
> 3. @user = User.find(:all, :conditions => [ "user_name = ?",
> '@some_variable'])
> 4. render_text @user.to_s

The method you're after is @user.inspect.  @user is an instance variable
of class (I presume) User.
Yehweh (Guest)
on 2005-11-19 23:55
> The method you're after is @user.inspect.  @user is an instance variable
> of class (I presume) User.

Yeah,I wanted to use @user.inspect.

Thanks.
This topic is locked and can not be replied to.