Active_Record_Base_Subclass_Error

Namespace 衝突エラー

  • エラー内容
     ArgumentError:
       The Item model class for the Items::UsageTag#item association is not an ActiveRecord::Base subclass.
     # ./spec/factories/items.rb:155:in `block (3 levels) in <top (required)>'

対応

  • テーブルネームprefix を削除
module Items
  def self.table_name_prefix
    "items_"
  end
end
  • テーブルを指定
module Items
  class Image
    self.table_name = "items_images".freeze
    belongs_to :item, class_name: "::Item"