On Fri, Feb 20, 2009 at 9:08 AM, Jonathan Stott
<[email protected]> wrote:
> To get the protection in ruby code too, you can use:
>
>  validates_is_unique :book_id, :scope => :author_id
>
> which scopes the SELECT for book_id checking to the post's author_id.
>

Thank you, Jon.
I understand that I should use

   validates_is_unique :book_id, :scope => :author_id

instead of:

   property :book_id,   Integer, :unique => :u1
   property :author_id, Integer, :unique => :u1


But It seems for me to be slightly strange that ':unique => :u1' is
not available.
Do you know the reason?

   ## ':index' option supports multi-columns.
   property :book_id,   Integer, :index => :u1           # OK
   property :author_id, Integer, :index => :u1           # OK

   ## ':unique_index' also supports multi-columns.
   property :book_id,   Integer, :unique_index => :u1    # OK
   property :author_id, Integer, :unique_index => :u1    # OK

   ## but only ':unique' doesn't support multi-columns. why?
   ## this style is more readable than validates_is_unique, I think.
   property :book_id,   Integer, :unique => :u1          # NG
   property :author_id, Integer, :unique => :u1          # NG


--
regards,
makoto kuwata

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to