Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # user model
- class User < ActiveRecord::Base
- has_one :portfolio
- has_one :event
- has_one :article
- validates_presence_of :login, :email, :password, :password_confirmation, :major, :graduation_year, :on => :create, :message => "You are missing one of the required fields"
- validates_format_of :login, :with => /^\w+$/, :message => "The LOGIN chosen is missing or invalid"
- validates_uniqueness_of :login, :on => :create, :message => "The LOGIN chosen is already being used"
- validates_length_of :login, :within => 6..40, :message => "The LOGIN chosen is too long or short - keep it between 6 and 40 characters"
- validates_uniqueness_of :email, :message => "The E-MAIL chosen is already chosen"
- validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid email"
- validates_length_of :password, :within => 6..20, :message => "The PASSWORD chosen is too long or short - keep it between 6 and 18 characters"
- validates_confirmation_of :password, :message => "The PASSWORD and PASSWORD CONFIRMATION fields do not match up"
- validates_acceptance_of :terms, :message => "You must accept the terms to proceed"
- attr_protected :id
- # members_controller
- def create
- user = User.new(
- :first_name => params[:user][:first_name],
- :last_name => params[:user][:last_name],
- :login => params[:user][:login],
- :password => params[:user][:password],
- :email => params[:user][:email],
- :phone => params[:user][:phone],
- :website => params[:user][:website],
- :current_city => params[:user][:current_city],
- :current_state => params[:user][:current_state],
- :major => params[:user][:major],
- :minor => params[:user][:minor],
- :graduation_year => params[:user][:graduation_year],
- :authtype => 0
- )
- user.save
- redirect_to :action => :all
- end
Add Comment
Please, Sign In to add comment