Hi all !
Is this supposed to work ?
class Email < ActiveRecord::Base
has_many :to, :class_name => ‘Recipient’, :conditions =>
“recipients.source = ‘to’” do
def create!(*args)
with_scope(:create => {:source => ‘to’}) do
super
end
end
def build(*args)
with_scope(:create => {:source => 'to'}) do
super
end
end
end
end
From my tests, if I call Email.to.create!, the recipient model
correctly has it’s source attribute set to ‘to’. On the other hand,
if I call #build, the recipient’s source is nil.
There must be something I’m doing wrong…
Thanks !
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/