Guest User

Untitled

a guest
Mar 10th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #CONTROLLER
  2. def update
  3. @user = User.find(params[:id])
  4.  
  5. if @user.update_attributes(params[:user])
  6. flash[:notice] = 'User was successfully updated.'
  7. redirect_to @user
  8. else
  9. @persons = Person.find(:all)
  10. render :action => 'edit'
  11. end
  12. end
  13.  
  14.  
  15. def edit
  16. @user = User.find(params[:id])
  17. @persons = Person.find(:all)
  18. end
  19.  
  20. #VIEW
  21. <% form_for(@user) do |f| %>
  22. <table>
  23. <tr>
  24. <td>Username:</td>
  25. <td><%= f.text_field :login -%></td>
  26. </tr>
  27. <tr>
  28. <td>Password:</td>
  29. <td><%= f.password_field :password -%></td>
  30. </tr>
  31. <tr>
  32. <td>Password again:</td>
  33. <td><%= f.password_field :password_confirmation -%></td>
  34. </tr>
  35. <tr>
  36. <td>Email:</td>
  37. <td><%= f.text_field :email -%></td>
  38. </tr>
  39. <tr>
  40. <td>Person:</td>
  41. <td><%= f.collection_select(:person_id, @persons, :id, :first_name) -%></td>
  42. </tr>
  43. </table>
  44. <% end %>
Add Comment
Please, Sign In to add comment