I''ve been doing stuff like
class Book < ActiveRecord::Base
has_many :contributions, :dependent => :destroy
has_many :contributors, :through => :contributions, :uniq => true
has_many :authors, :through => :contributions, :source
=> :author, :conditions => "contributions.role =
''author''" do
def <<(author)
Contribution.with_scope(:create => {:role => "author"})
{ self.concat author }
end
end
end
(which I stole from
http://blog.hasmanythrough.com/2006/8/19/magic-join-model-creation)
In 2.0 with_scope is protected, to discourage abuse. Is this still a
legitimate use of with_scope or is there a better pattern to follow ?
Fred
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---