我有一个简单的模块,它包含在我的模型中
module Inputable
extend ActiveSupport::Concern
included do
has_many :inputs, as: :inputable, dependent: :destroy
end
end
class Product < ActiveRecord::Base
include Inputable
end
但是当我尝试打电话时,Product.first.inputs
我遇到了错误
PG::UndefinedTable: ERROR: relation "inputs" does not exist
LINE 5: WHERE a.attrelid = '"inputs"'::regclass
: SELECT a.attname, format_type(a.atttypid, a.atttypmod)
Product.reflect_on_all_associations.map { |assoc| assoc.name}
=>[:inputs]
我的代码有什么问题?