Ruby on Rails Sunday, January 2, 2011

Colin Law wrote in post #971847:
> On 2 January 2011 14:11, Michal Burak <lists@ruby-forum.com> wrote:
>>>>
>> link1.save!
>>
>> foo2 = create_foo.save!
>> link2 = foo2.www_links.create(:href => 'wp.pl')
>>
>> # when
>> link2.save!
>>
>> # then
>> errors occured !
>> end
>
> So you are just wanting uniqueness of www_link.href? Will not
> validates_uniqueness_of in WwwLink class (backed up by a unique
> constraint in the database of course) do the job? I think in this
> case it will be the foo2.www_links.create that will fail.
>
> Colin


The constraint is on "owner" and "href", not "href" itself.
I can have multiple links with the same href. But those cannot be with
the same owner_id.

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