Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- See the below for the error info ....
- "nil is not a symbol"
- /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/validations.rb:296:in `send'
- /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/validations.rb:296:in `validates_each'
- /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/validations.rb:514:in `validates_uniqueness_of'
- #{RAILS_ROOT}/app/models/user.rb:25
- #{RAILS_ROOT}/app/controllers/application.rb:29:in `check_authorization'
- /usr/local/bin/mongrel_rails:18
- in user.rb
- # Fun easy validation
- validates_uniqueness_of :username, :on => :createuser, :message => "is already in the system."
- validates_uniqueness_of :username, :on => :updateuser, :message => "is already in the system."
- validates_uniqueness_of :email, :on => :createuser, :message => "is already in the system."
- validates_uniqueness_of :email, :on => :updateuser, :message => "is already in the system."
- validates_format_of :username, :with => /^[A-Za-z][A-Za-z0-9\-\_]{2,39}$/, :message => "can only consist of letters, numbers, -, and _"
- validates_format_of :first_name, :with => /^[A-Za-z0-9\-\s]*$/, :message => "can only consist of letters, numbers, -, and _"
- validates_format_of :middle_name, :with => /^[A-Za-z0-9\-\s]*$/, :message => "can only consist of letters, numbers, -, and _"
- validates_format_of :last_name, :with => /^[A-Za-z0-9\-\s]*$/, :message => "can only consist of letters, numbers, -, and _"
- validates_format_of :email, :with => /^([^@\s] )@((?:[-a-z0-9] \.) [a-z]{2,})$/, :message => "is not valid."
- validates_length_of :email, :maximum=> 100, :message => "may only be a maximum of 100 charactars."
- validates_length_of :ip_address, :maximum => 15, :message => "is too long (format: ###.###.###.###)."
- validates_length_of :first_name, :maximum => 40, :allow_nil => true
- validates_length_of :middle_name, :maximum => 40, :allow_nil => true
- validates_length_of :last_name, :maximum => 40, :allow_nil => true
- validates_presence_of :username, :email, :ipaddr
- validates_numericality_of :confirmed, :on => :createuser
- validates_numericality_of :confirmed, :on => :updateuser
- the newuser.rhtml
- <h2><span>Create User</span></h2>
- <%= start_form_tag({:action => "createuser", :controller => "admin"}, {:onSubmit => "Element.show('ident_spinner');" }) %>
- <%= render :partial => 'form_user' %>
- <%= end_form_tag %>
- the _form_user.rhtml
- <script>keepFlashAlive = true;</script>
- <!--[form:user]-->
- <dl>
- <dt>Username</dt>
- <dd>
- <%= text_field 'user', 'username' %>
- </dd>
- <dt>Password</dt>
- <dd>
- <%= password_field 'post', 'password_first' %>
- </dd>
- <dt>Re-type Password</dt>
- <dd>
- <%= password_field 'post', 'password_second' %>
- </dd>
- <dt>Email Address</dt>
- <dd>
- <%= text_field 'user', 'email' %>
- </dd>
- <dt>First Name</dt>
- <dd>
- <%= text_field 'user', 'first_name' %>
- </dd>
- <dt>Middle Name</dt>
- <dd>
- <%= text_field 'user', 'middle_name' %>
- </dd>
- <dt>Last Name</dt>
- <dd>
- <%= text_field 'user', 'last_name' %>
- </dd>
- <br /><br />
- <dd>
- <input type='submit' value='Submit' class='primary' />
- <%= image_tag('/images/admin/spinner_mac.gif', :align => 'absmiddle', :border=> 0, :id=>'ident_spinner', :style=>'display: none;' ) %>
- </dd>
- </dl>
- <!--[eoform:user]-->
- <%= params.inspect %>
- the admin controller ....
- def newuser
- @user = User.new()
- end
- def createuser
- @user = User.new(params[:user])
- @user.password = params[:post][:password_first]
- @user.password_hash
- @user.password_salt
- if @user.save
- flash[:notice] = "The user was successfully created."
- redirect_to :action => "listusers"
- else
- render :action => "newuser"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement