Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Added :counter_sql to valid keys for HABTM

#1102

In #831, I submitted a patch to refactor AssociationCollection#count and fix problems with HABTM count in Ruby 1.8.7. I forgot to add :counter_sql to the list of valid keys for HABTM associations in associations.rb, as Tekin pointed out. This was causing the option to be rejected despite the documentation update stating it should work. This one-liner patch fixes that. Sorry!

(If someone wants to add a new fixture that is a HABTM association with a :counter_sql option and put in a test making sure it counts, it probably would be worthwhile. I just don't have the time to do that today, and wanted to get this in before the bug makes it into 2.2 beta.)

Reported by Ernie Miller · September 24th, 2008 @ 02:37 PM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Michael Koziarski
    Michael Koziarski

    This doesn't apply cleanly any more, can you rebase it and reupload it please

    November 6th, 2008 @ 07:56 PM

  2. Tekin
  3. Michael Koziarski
    Michael Koziarski

    Also, we clearly don't have any tests for this feature, can you add a few (even just a simple declaration of the association and assertion on the count).

    November 6th, 2008 @ 08:16 PM

  4. Tekin
    Tekin

    OK, will try get some simply tests added to the patch.

    November 6th, 2008 @ 08:25 PM

  5. Ernie Miller
    Ernie Miller

    Tekin,

    Thanks for jumping on this so fast! You saved me the pain. :)

    November 6th, 2008 @ 08:26 PM

  6. Tekin
    Tekin

    No worries!

    Here's an updated patch with a couple of tests. Hope that does the trick.

    November 6th, 2008 @ 09:09 PM

  7. Repository
    Repository
    • State changed from new to committed

    (from [32a5cfcd7f8d14407f0c00ce2cdc82b1b568438e]) Added tests for HABTM associations with counter_sql

    Signed-off-by: Michael Koziarski michael@koziarski.com [#1102 state:committed] http://github.com/rails/rails/co...

    November 7th, 2008 @ 08:01 AM