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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3EbMQxRMf4gJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 27, '11 at 10:43a
activeSep 27, '11 at 10:43a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Rajeev Kannav Sharma: 1 post

People

Translate

site design / logo © 2022 Grokbase