Skip to content

association.include?(associated) fails oddly #5

@jamesarosen

Description

@jamesarosen

I have a owner model:

class Person < ActiveRecord::Base
  has_many_polymorphs :things, :from => [ :books, :cds, :dvds ], :through => :person_things
end

a relationship model:

class PersonThing < ActiveRecord::Base
  belongs_to :person
  belongs_to :thing, :polymorphic => true
end 

and several owned models:

class Book < ActiveRecord::Base
end
...

If I create a relationship:

person = Person.create!(:name => 'Barney')
book = Book.create!('Dinosaurs for Dummies')
person.things << book

then include? fails even when select doesn't:

person.things.include? book
# => false
person.things.select { |t| t == book }.any?
# => true

I'm guessing include? is redefined on this enumeration, but it's not redefined correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions