Hi,

I ve defined the following relation in one of my models with a dynamic
where condition:
has_one :selection,
          :foreign_key => 'object_id',
          :conditions => 'selection_type = 1 and account_id = #
{self.send(:account_id)}'

That works perfect, however when I try to eager load that relation I
am getting the following error when doing a count. Seems that self is
not really my model class anymore.... Does anybody know how I can get
that up and running?

Thanks a lot in advance

NoMethodError (undefined method `account_id' for
#<ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation:
0x4d5bf5c>):
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations.rb:1621:in `interpolate_sql'
    (eval):1:in `interpolate_sql'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations.rb:1600:in `association_join'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations.rb:1599:in `each'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations.rb:1599:in `association_join'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:184:in `construct_calculation_sql'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:184:in `collect'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:184:in `construct_calculation_sql'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:212:in `execute_simple_calculation'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:121:in `calculate'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:117:in `catch'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:117:in `calculate'
    C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/calculations.rb:45:in `count'




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