Hi,
I am trying to overwrite the accessor of a has_many association.
Basically my class looks like this:

class Person
  has_many :emails
  has_one :link, :class_name => 'PersonProxy'

  def emails_with_link
     link.emails + emails_without_link
  end
  alias_method_chain :emails, :link
end

Now that works fine if I only access the collection like
>> Person.find(1).emails
=> [#<Email...]

But using any collection specific methods throw a NoMethodError
>> Person.find(1).emails.build
=> NoMethodError: undefined method `build' for #<Array:0x226c634>

which makes sense, as I return an array...

But how do I return the Association? Or are there any other tricks to
implement this decorator for associations?

Cheers
Marcel

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