i'm having problem in checking validates_uniqueness_of which has two condtion.
Class name is InviteGuest
class InviteGuest < ActiveRecord::Base
attr_accessible :invite_id, :email, :first_name, :last_name, :random_no
validates_presence_of :invite_id, :unless => :random_no?
validates_uniqueness_of :email, :scope => [:invite_id]
Here i'm checking invite_id
or :random
number for presence.
so here my :email
feilds are entering first with unique :random_no
.which works fine.and i;m validates_uniqueness_of :email, :scope => [:invite_id]
but it's not allowing me to enter same :email
for different :random_no
. i have to put or condition. it's cheking for :invite_id
but i would like to check it for :random_no
if :invite_id
is not present. but it's not allowing me to enter :email
for different :random_no
.
Any idea??
It sounds to like your scope is not set correctly. You should scope on
random_no
: