Hi,
I have a form that asks users to put in their :first_name and
:last_name.
How do I validate that their full_name (first_name + last_name) is
unique?
Thanks!
Nguyen Anh Hung
Assistant Project Manager/ Consultant/ Business Analyst
Tech Propulsion Labs
Mobile: +84987 005 477
Twitter: http://www.twitter.com/anhhung
Blog: http://www.fresco20.com
Skype: anhhung.n | Yahoo: hero.tuxer | Gtalk: anhhung
You can use :scope
validates_uniqueness_of :first_name, :scope => :last_name
If your database is huge, indexing last_name will help. Read more here:
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html
Thanks,
Abhinav
अà¤à¤¿à¤¨à¤µ
http://twitter.com/abhinav
On Tue, Sep 8, 2009 at 9:59 AM, Anh Hung N. [email protected]
wrote:
Hi,
I have a form that asks users to put in their :first_name and :last_name.
How do I validate that their full_name (first_name + last_name) is
unique?