#16 √ invalid
jcarroll (at thoughtbot)

#should_have_many

Reported by jcarroll (at thoughtbot) | February 14th, 2008 @ 01:51 PM

Add support for :foreign_key options on #should_have_many

Comments and changes to this ticket

  • Tammer Saleh

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

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

    Hi Jared,

    should_have_many checks the association definition for a foreign_key statement, and will check the associated class for that column if it's set. So you shouldn't have to explicitly tell should_have_many what the foreign_key is.

    For example:

    class Dog < ActiveRecord::Base
      belongs_to :user, :foreign_key => :owner_id
    end
    
    class DogTest < Test::Unit::TestCase
      should_belong_to :user
    end
    

    In that instance, "should_belong_to :user" sees that the belongs_to relationship is specifying a foreign key, and will assert that the key is on the dog's table.

    Tammer

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 »

People watching this ticket