Ruby on Rails Sunday, January 2, 2011

On 2 January 2011 13:42, Michal Burak <lists@ruby-forum.com> 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

>
> My first attempt would be to write validation in Foo that checks all its
> www_links. But then I would also have to do it in WwwLink class. That
> would not be DRY.

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