activerecord-tableless icon indicating copy to clipboard operation
activerecord-tableless copied to clipboard

Rails 3.2.13 problems with has_many_through relationships

Open tilo opened this issue 12 years ago • 2 comments

In Rails 3.2.13 I'm experiencing problems when trying to use tableless models as one side of a has_many_through relationship

  class List < ActiveRecord::Base
     # persisted model
     has_many :memberships
     has_many :items , :through => :memberships
   ...
  end

  class Item < ActiveRecord::Base
    has_no_table :database => :pretend_success

    has_many :memberships
    has_many :lists , :through => :memberships

    ...
  end

  class Mermbership < ActiveRecord::Base
    # persisted model / join model
    belongs_to :list
    belongs_to :item
  end

  l = List.first
  l.items
  (Object doesn't support #inspect)

 l.items.class
 NoMethodError: undefined method 'supports_explain?' for #<Object:...>

tilo avatar Nov 23 '13 02:11 tilo

the faked connection needs to fake the select_all, select_value, select_values calls

tilo avatar Nov 25 '13 19:11 tilo

Thanks for investigating, can you provide a pull request...

jarl-dk avatar Nov 25 '13 20:11 jarl-dk