find results help!!!

As Dave said check what is in your @user variable with @user.inspect

Can you post the actual controller code, and the view code please. It’s a little hard to guess what’s happening

def show

@users = User.find(:all, :conditions => [ “user_id = ?”, params[:id] ])

end

You can change this to

def show
@users = User.find_all_by_id( params[:id] )

end

It will be auto sanitized for you.

You need to wrap up the view to run for each user. You’re passing it an array so you need to go through each element of it.

<% @users.each do |user| %>

<% for column in User.content_columns %>

<%= column.human_name %>: <%=h user.send([column.name](http://column.name)) %>

<% end %>

<%= link_to ‘Edit’, :action => ‘edit’, :id => user %> |
<%= link_to ‘Back’, :action => ‘list’ %>
<% end %>

That should do the trick for you. Please let me know if you don’t get anything there.

HTH
Daniel

mmm That’s strange. I’m able to use it. It’s a standard method.

Have you had a look in console to see what’s going on? This is really helpful.

Alternatively you could use a simple find_by_id

User.find_by_id( params[:id] )

But this changes it a bit. You don’t need to go through an array now since it will provide either a user record or nil

The controller action becomes

def show
@user = User.find_by_id( params[:id] )
end

And the view
<% unless @user.nil? %>
<% for column in User.content_columns
%>


<%= column.human_name %>: <%=h @user.send(column.name) %>

</p>

<% end %>

<%= link_to 'Edit', :action => 'edit', :id => @user %> |
<%= link_to 'Back', :action => 'list' %>

<% end %>
<% end %>

In your rails directory type

ruby script/console

This will give you a command prompt. You can type ruby in that will be executed in the rails environment

so
user = User.find
( :first )
should return the first user in the database.

Your user is an ActiveRecord class right?