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] ] ) %></td> </tr> <tr> <td></td> <td><input type="submit" value=" Edit User " /> </tr> </table> <%= 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) %></td> <td><%= link_to("(delete)", :action => :delete_user, :id => user.id) %></td> </tr> <% end -%> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/6130d9df/attachment-0001.html
Hello, I still cannot get this working. How do I edit a record without using scaffold? Thanks Frank ----- Original Message ----- From: Frank To: rails@lists.rubyonrails.org 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] ] ) %></td> </tr> <tr> <td></td> <td><input type="submit" value=" Edit User " /> </tr> </table> <%= 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) %></td> <td><%= link_to("(delete)", :action => :delete_user, :id => user.id) %></td> </tr> <% end -%> ------------------------------------------------------------------------------ _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/611788f6/attachment.html
nevermind, I had the controller edit coded wrong. Frank ----- Original Message ----- From: Frank To: rails@lists.rubyonrails.org 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: rails@lists.rubyonrails.org 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] ] ) %></td> </tr> <tr> <td></td> <td><input type="submit" value=" Edit User " /> </tr> </table> <%= 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) %></td> <td><%= link_to("(delete)", :action => :delete_user, :id => user.id) %></td> </tr> <% end -%> ---------------------------------------------------------------------------- _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails ------------------------------------------------------------------------------ _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/dab79632/attachment-0001.html