Problem retrieving user id

I have a problem, I use a find.params[:id] to display a user from a
list, and then I want to edit that information. I have a separate
action for the edit, named change_user_details, and I retrieve the
user id the same way I do for the audit_user with find.params[:id].
The problem is that the action change_user_details does not want to
retrieve the current viewed user id. It gives the error Couldn’t find
User without an ID.
Here is the code of the two actions and the two forms.

def audit_user
@user = User.find(params[:id])
end

def change_user_details
@user = User.find(params[:id])
end

Username: <%= @user.username %>

Email: <%= @user.email %>

IP: <%= @user.user_ip %>

First Name: <%= @user.firstname %>

Last Name: <%= @user.lastname %>

<%= link_to(‘Change’, :action => ‘change_user_details’) %>
|
<%= link_to(‘Back’, :action => ‘list_users’) %>

Editing User Information

<% form_tag :action => ‘update_user’, :id => @user do %>

Firstname
<%= text_field 'user', 'firstname' %>

Last Name
<%= text_field 'user', 'lastname' %>

Email
<%= text_field 'user', 'email' %>

<%= submit_tag(“Update”)%>

<% end %>

<%= link_to(‘Back’, :action => ‘audit_user’) %>

Hi

Perhaps you can take a look at activescaffold…

CCH

On Oct 16, 6:58 pm, “[email protected]

Thanks, took care of the problem :slight_smile:

Yep, it worked. Before that I used a newly created session to track the
id.
But it worked. Thanks a lot.

On 10/16/07, [email protected] [email protected] wrote:

I have a problem, I use a find.params[:id] to display a user from a
list, and then I want to edit that information. I have a separate
action for the edit, named change_user_details, and I retrieve the
user id the same way I do for the audit_user with find.params[:id].
The problem is that the action change_user_details does not want to
retrieve the current viewed user id. It gives the error Couldn’t find
User without an ID.

Right, because params[:id] is empty.

Username: <%= @user.username %>

Email: <%= @user.email %>

IP: <%= @user.user_ip %>

First Name: <%= @user.firstname %>

Last Name: <%= @user.lastname %>

<%= link_to(‘Change’, :action => ‘change_user_details’) %>

This doesn’t pass an id. You need to explicitly pass it:

<%= link_to ‘Change’, :action => ‘change_user_details’, :id => @user
%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs