I'm running into an issue where I'm defining an association extension:

class User < ActiveRecord::Base

has_many :credentials do
  def update(key,val)
    cr = proxy_target.select{ |c| c.id == key.to_i}.first
    cr.update_attributes(val) unless cr.nil?
  end
end

This code fails, because proxy_target == [], unless the association
has been loaded already, i.e. someone called user.credentials prior to
this.

In activerecord-2.0.2/active_record/associations/association_proxy.rb,
there is

def proxy_target
        @target
end

I wonder if this should be

def proxy_target
        load_target
        @target
end

Thanks,

Wolf
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to