【发布时间】:2017-03-31 13:58:41
【问题描述】:
我有一个简单的模块,它包含在我的模型中
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?愚蠢的问题,但我想我会问。 -
你说得对,我没有
-
你能告诉我们你的输入迁移的代码和输入模型吗?
标签: ruby-on-rails activerecord activesupport activesupport-concern