Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Setting a belongs_to association to nil raise an error (NoMethodError: undefined method `length' for nil:NilClass) #104

Merged
merged 1 commit into from May 20, 2012

Conversation

Projects
None yet
2 participants

ActiveRecord will set this "attribute" to nil right here:

    def replace_keys(record)
      if record
        owner[reflection.foreign_key] = record[reflection.association_primary_key(record.class)]
      else
        owner[reflection.foreign_key] = nil
      end
    end

so we need to allow nil as a valid value.

cfis added a commit that referenced this pull request May 20, 2012

Merge pull request #104 from TylerRick/belongs_to_setting_to_nil
Setting a belongs_to association to nil raise an error (NoMethodError: undefined method `length' for nil:NilClass)

@cfis cfis merged commit df60c15 into composite-primary-keys:master May 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment