Help - edit without using scaffold

Hello,

What am I doing wrong? The code below does not show the current record
for editing.

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

def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = ‘User was successfully updated.’
redirect_to :action => ‘show’, :id => @user
else
render :action => ‘edit’
end
end


Editing user

<%= form_tag :action => 'update', :id => @user %>
User Name: <%= text_field("user", "username") %>
Login: <%= text_field("user", "login") %>
Password: <%= password_field("user", "password") %>
Email: <%= text_field("user", "email") %>
Security: <%= select("user", "role", [ ['User', 1], ['Supervisor', 2], ['Administrator', 3] ] ) %>
<%= end_form_tag %> <%= link_to 'Show', :action => 'show', :id => @user %> | <%= link_to 'Back', :action => 'list_users' %>
<% for user in @all_users -%> <% end -%>
<%= user.username %> <%= link_to("(edit)", :action => :edit_user, :id => user.id) %> <%= link_to("(delete)", :action => :delete_user, :id => user.id) %>

Hello,

I still cannot get this working.
How do I edit a record without using scaffold?

Thanks

Frank
----- Original Message -----
From: Frank
To: [email protected]
Sent: Thursday, January 05, 2006 1:13 PM
Subject: [Rails] help - edit without using scaffold

Hello,

What am I doing wrong? The code below does not show the current record
for editing.

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

def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = ‘User was successfully updated.’
redirect_to :action => ‘show’, :id => @user
else
render :action => ‘edit’
end
end


Editing user

<%= form_tag :action => 'update', :id => @user %>
User Name: <%= text_field("user", "username") %>
Login: <%= text_field("user", "login") %>
Password: <%= password_field("user", "password") %>
Email: <%= text_field("user", "email") %>
Security: <%= select("user", "role", [ ['User', 1], ['Supervisor', 2], ['Administrator', 3] ] ) %>
<%= end_form_tag %> <%= link_to 'Show', :action => 'show', :id => @user %> | <%= link_to 'Back', :action => 'list_users' %>
<% for user in @all_users -%> <% end -%>

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

<%= user.username %> <%= link_to("(edit)", :action => :edit_user, :id => user.id) %> <%= link_to("(delete)", :action => :delete_user, :id => user.id) %>

nevermind, I had the controller edit coded wrong.

Frank
----- Original Message -----
From: Frank
To: [email protected]
Sent: Thursday, January 05, 2006 3:10 PM
Subject: Re: [Rails] help - edit without using scaffold

Hello,

I still cannot get this working.
How do I edit a record without using scaffold?

Thanks

Frank
----- Original Message -----
From: Frank
To: [email protected]
Sent: Thursday, January 05, 2006 1:13 PM
Subject: [Rails] help - edit without using scaffold

Hello,

What am I doing wrong? The code below does not show the current 

record for editing.

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

def update
  @user = User.find(params[:id])
  if @user.update_attributes(params[:user])
    flash[:notice] = 'User was successfully updated.'
    redirect_to :action => 'show', :id => @user
  else
    render :action => 'edit'
  end
end
********************************************************************
<h1>Editing user</h1>
<%= form_tag :action => 'update', :id => @user %>
<table>
 <tr>
  <td>User Name:</td>
  <td><%= text_field("user", "username") %></td>
 </tr>
 <tr>
  <td>Login:</td>
  <td><%= text_field("user", "login") %></td>
 </tr>
 <tr>
  <td>Password:</td>
  <td><%= password_field("user", "password") %></td>
 </tr>
 <tr>
  <td>Email:</td>
  <td><%= text_field("user", "email") %></td>
 </tr>
 <tr>
  <td>Security:</td>
  <td><%= select("user", "role", [ ['User', 1], ['Supervisor', 2], 

[‘Administrator’, 3] ] ) %>






<%= end_form_tag %>
<%= link_to ‘Show’, :action => ‘show’, :id => @user %> |
<%= link_to ‘Back’, :action => ‘list_users’ %>

********************************************************************
<table>
<% for user in @all_users -%>
<tr>
  <td><%= user.username %></td>
  <td><%= link_to("(edit)", :action => :edit_user, :id => user.id) 

%>
<%= link_to(“(delete)”, :action => :delete_user, :id =>
user.id) %>

<% end -%>


_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails