#19 √ committed
Earle Clubb

[patch] pluralization problem in should_belong_to

Reported by Earle Clubb | February 21st, 2008 @ 01:45 PM

Same problem and fix as ticket #18. Patch attached.

Comments and changes to this ticket

  • Tammer Saleh

    Tammer Saleh February 28th, 2008 @ 04:36 PM

      • → State changed from “new” to “open”

    Hi Earle,

    I'm not sure I see the issue. Could you upload an example test that doesn't work as expected?

    Tammer

  • Anthony Caliendo

    Anthony Caliendo March 3rd, 2008 @ 01:33 PM

    There was an issue opened against #classify in Rails 2. Please see this Rails Trac issue: http://dev.rubyonrails.org/ticke... .

    The gist of it is that "address".classify will return "Addres" instead of "Address". The reason for this is because the #classify method is expected to be passed the plural form, not the singular form.

    I took the advice listed in the rails bug and changed line 385 in active_record_helpers.rb to use #camelize instead of #classify (see attached patch). The unit test in my code which was failing before worked after this change (I didn't include the test in the patch since it was specific to my codebase). I was using shoulda revision 378.

    I'm not sure if there would be any side effects from this change, but I hope this information helps.

  • Anthony Caliendo

    Anthony Caliendo March 3rd, 2008 @ 01:37 PM

    I just realized that Earle's patch was exactly the same as mine, so I removed it. Sorry for not seeing your attachment sooner!

    However, the reason for the failure remains the same.

  • Anthony Caliendo

    Anthony Caliendo March 3rd, 2008 @ 01:45 PM

    I am attaching a failing test for this issue, which demonstrates that the fix works.

  • Tammer Saleh

    Tammer Saleh June 26th, 2008 @ 03:25 PM

      • → State changed from “open” to “new”
      • → Assigned user cleared.
      • → Tag cleared.
  • Ryan McGeary

    Ryan McGeary August 8th, 2008 @ 07:07 PM

      • → State changed from “new” to “committed”
      • → Assigned user changed from “” to “Ryan McGeary”
      • → Tag changed from “” to “should_belong_to”

    Thanks Earle and Anthony.

    This is now fixed: http://github.com/thoughtbot/sho...

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »