rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] Validates uniqueness scope

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

In a Rails 2.x validation to check if the name of some model is unique
within a some category, I would use:

`validates_uniqueness_of :name, :scope => :category_id`

In Rails 3, this is replaced with:

`validates :name, :uniqueness => true`

However, I can't seem to find a method of defining the uniqueness'
scope. Am I missing something?

Thanks,
Angelo

--
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 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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive