我有簡單的模塊,並將其納入到我的模型關係不存在的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
你能告訴我們你的輸入偏移和輸入模型的代碼嗎? –