First off, THANK YOU for the time you have put into this plugin. This is functionality badly needed in core.
I'm having trouble getting it to work. Not sure if what i'm seeing is version specific, but it is ugly.
Installing the plugin breaks existing has_many :through and has_one :through associations.
The SQL generated for has_many :through is using the wrong value for the join ID (appears to be using the local id, rather than the id of the intermediary model?). I monkey-patched this by changing line 20 lib/nested_has_many_through.rb to:
"#{@nested_join_attributes[:remote_key]} = #{@owner.send(@nested_join_attributes[:local_key])} #{@nested_join_attributes[:conditions]}"
However, this "fix" breaks has_one :through associations, trying to put the wrong id (the :remote_key, it seems?) on @owner model.
As noted in Issue #1, has_one :through has it's own problems anyway.
I forked, I combed through the code, I did some debug outs, traced what was happening, but could not identify the cause of these issues. Perhaps it is something with the way it is interacting with Rails? Especially Rails 2.3?
There are no references to "has_one" in the plugin, so maybe that just isn't handled at all? Any insights you have would be appreciated.
Again, thank you for taking on the burden of maintaining this essential tool.
Broke my has one too....
class Artist < User
has_many :agents_artists, :dependent => :destroy has_many :agents, :through => :agents_artists has_one :primary_agent, :through => :agents_artists, :conditions => ["agents_artists.primary_agent = ?",true] , :source => :agent
I got it working by using one of the other forks. I think it may have been JackDanger or logophobia. I can't remember which one now. There's a reference to it in one of the commit messages.
Thanks, yes, I checked out the lighthouse site for this plugin and someone mentioned that there was a fork that worked and it did.