Guest User

Untitled

a guest
Mar 2nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # user model
  2. class User < ActiveRecord::Base
  3.  
  4. has_one :portfolio
  5. has_one :event
  6. has_one :article
  7.  
  8. validates_presence_of :login, :email, :password, :password_confirmation, :major, :graduation_year, :on => :create, :message => "You are missing one of the required fields"
  9.  
  10. validates_format_of :login, :with => /^\w+$/, :message => "The LOGIN chosen is missing or invalid"
  11. validates_uniqueness_of :login, :on => :create, :message => "The LOGIN chosen is already being used"
  12. validates_length_of :login, :within => 6..40, :message => "The LOGIN chosen is too long or short - keep it between 6 and 40 characters"
  13.  
  14. validates_uniqueness_of :email, :message => "The E-MAIL chosen is already chosen"
  15. validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid email"
  16.  
  17. validates_length_of :password, :within => 6..20, :message => "The PASSWORD chosen is too long or short - keep it between 6 and 18 characters"
  18. validates_confirmation_of :password, :message => "The PASSWORD and PASSWORD CONFIRMATION fields do not match up"
  19.  
  20. validates_acceptance_of :terms, :message => "You must accept the terms to proceed"
  21.  
  22.  
  23. attr_protected :id
  24.  
  25.  
  26.  
  27. # members_controller
  28. def create
  29. user = User.new(
  30. :first_name => params[:user][:first_name],
  31. :last_name => params[:user][:last_name],
  32. :login => params[:user][:login],
  33. :password => params[:user][:password],
  34. :email => params[:user][:email],
  35. :phone => params[:user][:phone],
  36. :website => params[:user][:website],
  37. :current_city => params[:user][:current_city],
  38. :current_state => params[:user][:current_state],
  39. :major => params[:user][:major],
  40. :minor => params[:user][:minor],
  41. :graduation_year => params[:user][:graduation_year],
  42. :authtype => 0
  43. )
  44. user.save
  45. redirect_to :action => :all
  46. end
Add Comment
Please, Sign In to add comment