Skip to content

Seems totally broken on Rails 2.3.2 #2

@brookr

Description

@brookr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions