Guest User

Untitled

a guest
Apr 26th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. # user_controller.rb
  2. def signup
  3. @user = User.new(params[:user])
  4. if request.post?
  5. if @user.save
  6. session[:user] = User.athenticate(@user.email, @user.password)
  7. flash[:notice] = "Signup successful."
  8. redirect_to :action => "index"
  9. else
  10. flash[:error] = "Failed signup."
  11. end
  12. end
  13. end
  14.  
  15. <fieldset>
  16. <%= error_messages_for "user" %>
  17.  
  18. <legend>Signup</legend>
  19. <% form_for :user do |f| %>
  20. <%= f.label :login, "Screen Name:" %>
  21. <%= f.text_field :login %>
  22.  
  23. <%= f.label :email, "Email:" %>
  24. <%= f.text_field :email %>
  25.  
  26. <%= f.label :password, "Password:" %>
  27. <%= f.password_field :password %>
  28.  
  29. <%= f.label :password_confirmation, "Confirm Password:" %>
  30. <%= f.password_field :password_confirmation %>
  31. <% end %>
  32.  
  33. <label for="gender"> I am: </label>
  34. <%= radio_button :user, :gender, "Male" %> Male
  35. <%= radio_button :user, :gender, "Female" %> Female
  36.  
  37. <label for="birthday"> Birthday: </label>
  38. <%= date_select :user,
  39. :birthday,
  40. :start_year => User::START_YEAR,
  41. :end_year => Time.now.year,
  42. :include_blank => true,
  43. :order => [:day, :month, :year] %>
  44.  
  45. <%= submit_tag "Signup", :class => "submit" %>
Add Comment
Please, Sign In to add comment