accepts_nested_attributes_for is not working for uniqueness

40 views
Skip to first unread message

Rajeev Kannav Sharma

unread,
Sep 27, 2011, 6:43:47 AM9/27/11
to rubyonra...@googlegroups.com
class User < ActiveRecord::Base
  accepts_nested_attributes_for :emails,      :allow_destroy => true,   :reject_if => proc { |attributes| attributes['address'].blank? }
end


class Email < ActiveRecord::Base
  belongs_to :user
  validates_presence_of :address
  validates_email_format_of :address
  validates_uniqueness_of :address, :scope=>'user_id'
end

when i am saving multiple same emails at one time it is saving , but it should not

Please suggest what i am missing 

Thanks
Rajeev sharma 
Reply all
Reply to author
Forward
0 new messages