Colin Law wrote in post #971843:
> On 2 January 2011 13:42, Michal Burak <[email protected]> wrote:
>> class Foo < ActiveRecoed::Base
>> has_many :www_links, :as => :owner
>> end
>>
>> class WwwLink < ActiveRecord::Base
>> belongs_to :owner, :polymorphic => true
>> attr_accessible :href
>> end
>>
>> I want to ensure that each Foo instance does not have same links (href).
>
> I don't understand what you mean by the above.
>
> Colin

  test "should not allow for adding two same links" do
    # given
    foo1 = create_foo.save!
    link1 = foo1.www_links.create(:href => 'wp.pl')
    link1.save!

    foo2 = create_foo.save!
    link2 = foo2.www_links.create(:href => 'wp.pl')

    # when
    link2.save!

    # then
    errors occured !
  end


I will put this logic in WwwLinks controller.

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

Reply via email to