Guest User

Untitled

a guest
Mar 6th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. ## controller
  2. def register
  3. @h1 = "Register"
  4. @user ||= User.new
  5.  
  6. if request.post?
  7. if @user.save
  8. end
  9. end
  10. end
  11.  
  12. ## view
  13. <%= error_messages_for 'user' %>
  14. <%= start_form_tag ({:action => :register}, {:method => "post"}) %>
  15. <table>
  16. <tr><td class="category">Username:</td><td><%= text_field('user','username') %></td></tr>
  17. <tr><td class="category">Password:</td><td><%= password_field('user','password') %></td></tr>
  18. <tr><td class="category">Password Confirm:</td><td><%= password_field('user','password_confirmation') %></td></tr>
  19. </table>
  20. <input type="submit" name="submit" value="Register" />
  21. <%= end_form_tag %>
  22.  
  23. ## model
  24. class User < ActiveRecord::Base
  25. validates_presence_of :username, :password
  26. validates_confirmation_of :password
  27. end
Add Comment
Please, Sign In to add comment