Guest User

Untitled

a guest
Mar 4th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. ## users_controller.rb
  2. class UsersController < ApplicationController
  3. # Be sure to include AuthenticationSystem in Application Controller instead
  4. include AuthenticatedSystem
  5. # If you want "remember me" functionality, add this before_filter to Application Controller
  6. before_filter :login_from_cookie
  7.  
  8. # render new.rhtml
  9. def new
  10. end
  11.  
  12. def create
  13. @user = User.new(params[:user])
  14. @user.save!
  15. self.current_user = @user
  16. redirect_back_or_default('/')
  17. flash[:notice] = "Thanks for signing up!"
  18. rescue ActiveRecord::RecordInvalid
  19. render :action => 'new'
  20. end
  21.  
  22. def index
  23. @user_pages, @users = paginate :users, :per_page => 10
  24. end
  25.  
  26. def edit
  27. @user = User.find(params[:id])
  28. end
  29.  
  30. def update
  31. flash[:notice] = "Nothing updated... no action yet"
  32. redirect_back_or_default('/')
  33. end
  34.  
  35. end
  36.  
  37. ## edit.rhtml
  38. <h2>Edit <%= @user.login %></h2>
  39.  
  40. <% form_tag :url => user_path(@user), :html => {:method => :put} do %>
  41. <%= error_messages_for 'user' %>
  42.  
  43. <!--[form:user]-->
  44. <p><label for="user_login"><b>Login:</b></label> <%= @user.login %></p>
  45.  
  46. <p><label for="user_password">Change password:</label><br/>
  47. <%= password_field 'user', 'password' %></p>
  48.  
  49. <p><label for="user_password_confirmation">Confirm:<label><br/>
  50. <%= password_field 'user', 'password_confirmation' %></p>
  51.  
  52.  
  53. <!--[eoform:user]-->
  54.  
  55. <%= submit_tag 'Edit' %>
  56. <% end %>
  57.  
  58. <%= link_to 'Show', user_path(@user) %> |
  59. <%= link_to 'Back', :action => 'index' %>
Add Comment
Please, Sign In to add comment