[Rails] Re: Validates_uniqueness_of problem

2010-02-11 Thread Sharagoz --
I dont understand why you want to validate uniqueness only on create. Isnt it a problem if email is changed later to an address that already exists? The :on parameter is not available for validates_uniqueness_of, probably because it doesnt make any sense. If you really want to make the

[Rails] Re: Validates_uniqueness_of problem

2010-02-11 Thread Hemant Bhargava
The reason that your approach doesn't work is that you're still calling validates_uniqueness_of on your class. This is telling it, from now on, check uniqueness of this column any time the record is saved. In effect, it's no different from just putting that code directly in the class body.

[Rails] Re: Validates_uniqueness_of problem

2010-02-11 Thread Frederick Cheung
On Feb 11, 12:51 pm, Mat Brown m...@patch.com wrote: class ModelName   validates_uniqueness_of :email, :if = proc { |model| model.new_record? } end and in cases like this where you just want to call a method you can do :if = :new_record? Fred -- You received this message because you are

Re: [Rails] Re: Validates_uniqueness_of problem

2010-02-11 Thread Mat Brown
On Thu, Feb 11, 2010 at 11:57, Frederick Cheung frederick.che...@gmail.com wrote: On Feb 11, 12:51 pm, Mat Brown m...@patch.com wrote: class ModelName   validates_uniqueness_of :email, :if = proc { |model| model.new_record? } end and in cases like this where you just want to call a method