search for: validates_confirmation_of

Displaying 20 results from an estimated 49 matches for "validates_confirmation_of".

2006 Jan 20
8
validates_confirmation_of not working
is there any special requirement for validates_confirmation_of ? I am trying to make sure 2 passwords are equal (cleanly the rails way).. In my view i have two fields with id user[password] and user[password_confirmation]. in the model i have validates_confirmation_of :password, :message =>"Passwords do not match " Am i missing something her...
2007 Oct 23
11
validates_confirmation_of not working?
I just can''t get validates_confirmation_of working for the life of me!... It''s not the first time I''m having problems with it but I just never understand why!... This time I pretty much followed *exactly* the example in Agile Rails Development and still...it just won''t work! I put 2 different passwords in the for...
2005 Oct 14
7
validates_confirmation_of not working
...ssword_confirmation = confirmation if valid? and oldpass == passhash save! else # valid? method clears errors so we have to call this after it errors.add_to_base ''Invalid current password'' unless oldpass == passhash false end end I also have validates_confirmation_of :password at the bottom of my model. At some point in time (can''t remember when), the valid? method stopped complaining when a confirmation isn''t provided. I have logged the values of self.password and self.password_confirmation at the point that valid? is called and self.passwo...
2006 Jul 31
0
validates_confirmation_of won''t work
...n this, forgive me but the search isn''t working right now. I seem to have a problem validating confirmation of a password. The first two snippets are some model code and some test code that work just fine: ---------------------------- class Challenge < ActiveRecord::Base ... validates_confirmation_of :title ... ---------------------------- class ChallengeTest < Test::Unit::TestCase ... def test_create c = Challenge.new assert !c.save c.title = c.title_confirmation = "some random title" c.body = "some body text" assert c.save end ---------...
2006 Mar 14
4
validates_confirmation_of has stopped working
Hi Railers, I''m past considering myself a noob in Rails land - I think what I''m up against here is more of a bug or an anomaly that I''m unaware of (or that has changed in a recent version). I had a fully working validates_confirmation_of :email_address field in my app - was one of the first things I set up, extremely simple, been working for a long time. Then one day I notice that it''s not working any more - the validator basically doesn''t care if you fill in the email_address field but not email_address_conf...
2006 Aug 16
6
modeling ''phony'' fields.
...email address by typing it in again. However, the user might change things on their account not related to their email address, such as their phone number, and they should not have to confirm their email address. I suppose I can add an email_confirmation field to the database, and then use validates_confirmation_of :email But, this seems rather wasteful and silly to store both the email and the email_confirmation. I understand that the model need not store the field in the database, but then in that case User.find(:first) ... fiddle with attributes other than email address ... User.save (rightly) throws...
2007 Oct 24
8
validates_confirmation_of not working
Hello to everyone, Well, very frustrated with this one because I am following the example straight from the documentation and it is not working. First when I try: validates_confirmation_of :password, :on => :password_update (password_update is a def in my User model which works fine without this validation in please) I get the following error: TypeError in UsersController#update_password nil is not a symbol [Full trace at the end of this message.] However, if I do only this:...
2006 Apr 26
1
Possible acts_as_authenticated bug (or rails)
...validations that look like this: validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, :if => :password_required? validates_length_of :password, :within => 5..40, :if => :password_required? validates_confirmation_of :password, :if => :password_required? I though the validations_presence_of :password_confirmation was a bit redundant, so I removed it. Unfortunately, that breaks the password_required? method. Here''s how I fixed it: def password_required? logger.debug(''...
2006 Aug 14
3
validating required fields during an update?
I have a User model with an email attribute. I''m using the following validations: validates_confirmation_of :email validates_format_of :email, :with => RFC822::EmailAddress, :message => "must be a valid address in the form user@domain.com" validates_uniqueness_of :email, :message => "address has already been taken. If you''ve forgotten your password, please clic...
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and password_confirmation), using the update_attributes method, i am getting errors thrown up by this validat...
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
...t;is already being used" validates_exclusion_of :subdomain, :in => %w{ www blog weblog forum info }, :message => "invalid subdomain" user.rb validates_presence_of :login validates_uniqueness_of :login, :on => :create validates_length_of :login, :within => 3..40 validates_confirmation_of :password, :if => Proc.new { |u| u.password.size > 0} validates_length_of :password, :within => 5..40, :on => :create My problem is that if there are issues with the user validation, the account has already been saved, so when the user fixes the fields and resubmits the validates_uni...
2006 Jan 19
4
validates_presence_of
I am just going through the book and I come across a problem with the code in the app/models: validates_format_of :image_url, :with => %r{^http:.+\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG, or PNG image" It seems to moan when it''s empty even though I removed :image_url from validates_presence_of. How should I make it optional?
2013 May 19
5
update_attributes() for a single column
I was just faced with a strange ROLLBACK exception when attempting to execute this code: $ rails console user = User.first User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => #<User id: 1, name: "Michael Hartl", email: "foo-+RB1Aph5k6s@public.gmane.org", created_at: "2013-05-12
2006 Nov 06
4
Confirmation fields on forms
I am unsure how to use a confirmation only field in my forms. The perfect example is when registering a user, you want them to type their password twice but you only want to have one record for it. The form fields; user[password] user[password_confirmation] form posted; user = User.new @params[:user] Error is thrown because there is no method for password_confirmation. -- Posted via
2006 Jul 24
6
error_messages_for not working
...is just getting displayed on a different page if I dont have the rescue block commented at the bottom. Model: user.rb require "digest/sha1" class User < ActiveRecord::Base validates_presence_of :eaddress, :fname, :passwd, :pcode, :country, :day, :year, :month, :gender, :agreement validates_confirmation_of :passwd validates_uniqueness_of :eaddress validates_length_of :eaddress, :within => 6..255 validates_numericality_of :pcode end View: index.rhtml ... <table class="compbox" cellpadding="0" cellspacing="0"> <tr><td class="panelheader">...
2006 Apr 04
2
how to perform client side validations in RoR?
Hi, I have a form for user registration. In that form there are fields for password & confirm_password. Now in my database there is column corresponding to password field. Now at clicnt side I want to validate equality of password & confirm_password field. How to do that? I have downloaded one password validator plugin & tried to used it. But it requirs two seperate fields in
2006 Apr 13
1
Model is not a class
...rd::Base validates_presence_of :email, :email_confirmation, :username, :password, :password_confirmation validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i validates_uniqueness_of :username validates_length_of :password, :within => 6..20 validates_confirmation_of :email, :password def self.authenticate(username, password) find_first(["username=? AND password=?", username, password]) end end and this is my controller: class Account::AuthController < ApplicationController model :account ..... end I guess the problem is th...
2006 Dec 16
2
Validate some fields only on object creation, not update
I''m having a problem with my User model. Originally I had alot of validation, including this: validates_presence_of :password_confirmation, :password validates_length_of :password, :within => 4..50 validates_confirmation_of :password However, this made it impossible to edit a user without setting his password, which I don''t want. So I tried to isolate the above validations in the before_create method, but that didn''t work too well: "undefined method validates_presence_of for model <User>...
2006 Feb 27
4
update_attribute with Validation?
Does anyone know of a way to update individual attributes with validation? update_attribute disables the validation checks in the record model, so I''m wondering if there''s a workaround for this. In my application, I want to allow the user to update some or all the attributes without having to enter :password and :password_confirmation, both of which are subject to
2006 Jul 06
1
Problem implementing password and password confirmation
...e example, but just can''t make any progress. User DB has these fields: ========================= t.column :name, :string, :limit => 40 t.column :hashed_password, :string t.column :salt, :string User model has: =============== attr_accessor :password_confirmation validates_confirmation_of :password # ''password'' is a virtual attribute def password @password end def password=(pwd) @password = pwd create_new_salt self.hashed_password = User.encrypted_password(self.password, self.salt) end Controller ========== def create @user = Us...