Any joy getting this to work with has_one :through in 2.1?

1 view
Skip to first unread message

RobW

unread,
Jun 11, 2008, 9:27:20 AM6/11/08
to nested_has_many_through
So far your plugin looks great, but it seems to rewrite my simple (not
nested) has_one :through association options which results in invalid
queries. I'm just digging into the code base now...

Cheers,

Rob

RobW

unread,
Jun 11, 2008, 9:59:56 AM6/11/08
to nested_has_many_through
OK. A little hacking later...

lib/nested_has_many_through.rb:

<< used alias_method_chain for construct_conditions and
construct_joins >>

init.rb:

require 'nested_has_many_through'

ActiveRecord::Associations::HasManyThroughAssociation.send :include,
NestedHasManyThrough::Association
ActiveRecord::Reflection::AssociationReflection.send :include,
NestedHasManyThrough::Reflection

ActiveRecord::Associations::HasOneThroughAssociation.class_eval do
def construct_conditions
construct_conditions_without_nested_has_many_through
end
def construct_joins
construct_joins_without_nested_has_many_through
end
end

Not exactly a thing of beauty but it does appear to work. I really
need to get my ass on github :-)

Ian White

unread,
Jun 11, 2008, 10:09:28 AM6/11/08
to nested_has_...@googlegroups.com
Cheers Rob for this, I'm in the middle of soul-destroying hacking and
debugging an old project for a client right now. I'll look over this
stuff tonight. Do all the specs pass? (Dosn't matter if you haven't
run them, I will). If they do I'll add these changes.

--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE
Mob: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>


Reply all
Reply to author
Forward
0 new messages