Thank you. But i have finished all the works. SO i can't do your first
method. But i did a custom validation fn and it works. Thanks anyway
tron wrote:
other address is
> belongs_to :user
> acts_as_list :scope => user_id
> validates_uniqueness_of :address
>
> Alternatively, if email and alt_email are just text columns in your
> user table, just write a validation function
> that checks uniqueness on the two columns (both compulsary).
>
> validates_each :email, :alt_email do |record,attr,value|
> if value.blank?
> record.errors.add attr, "cannot be blank"
> else
> email_taken = find(:conditions => ['(users.email = ? OR
> users.alt_email = ?) AND users.id != ?', value, value, record.id])
> record.errors.add attr, "(#{value}) is already taken" if
> email_taken
> end
> end
>
> Hope this helps
> Vik
>
> On Jan 20, 7:44�am, Rock Roll <[email protected]>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---