Hi,
when I use belongs_to with both counter_cache and foreign_key it doesn't update the counter cache correctly, since the update_counters method always operates on the table's primary key, instead of the foreign_key relevant in this case - as can be seen here.
I guess what could be done is to add a parameter holding the column that id references, which evaluates to the table's primary_key by default. This would have to be passed on by belongs_to when using increment_counter and decrement_counter here.
Should I try to make a pull request (would be my first to rails)? If yes, could someone please point me to file(s) appropriate fro the tests?
Cheers, Arno
Hi,
when I use belongs_to with both counter_cache and foreign_key it doesn't update the counter cache correctly, since the update_counters method always operates on the table's primary key, instead of the foreign_key relevant in this case - as can be seen here.
I guess what could be done is to add a parameter holding the column that id references, which evaluates to the table's primary_key by default. This would have to be passed on by belongs_to when using increment_counter and decrement_counter here.
Should I try to make a pull request (would be my first to rails)? If yes, could someone please point me to file(s) appropriate fro the tests?
Cheers, Arno