尝试范围:名称为View的父级:表单
上的属性class View < ActiveRecord::Base
belongs_to :form
delegate :facility_id, to: :form
validates_uniqueness_of :name, scope: :facility_id
attr_accessible :name
为什么不在表单上查找facility_id?
而是在View
上查找它ActiveRecord::StatementInvalid - PG::UndefinedColumn: ERROR: column views.facility_id does not exist
答案 0 :(得分:0)
我相信这段时间以前曾经有过工作,很有可能它仍然有效:
validates_uniqueness_of :name, scope: { :form => :facility_id }