我有简单的模块,并将其纳入到我的模型关系不存在的ActiveSupport ::关注
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]
什么是错的用我的代码?
您是否生成了输入模型并运行'rake db:migrate'?愚蠢的问题,但我想问问。 – jvillian
你是对的,我没有 – user
你能告诉我们你的输入偏移和输入模型的代码吗? –