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 %>
Email: <%= @user.email %>
IP: <%= @user.user_ip %>
First Name: <%= @user.firstname %>
Last Name: <%= @user.lastname %>
IP: <%= @user.user_ip %>
First Name: <%= @user.firstname %>
Last Name: <%= @user.lastname %>
First Name: <%= @user.firstname %>
Last Name: <%= @user.lastname %>
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’) %>