我在注册表之间有多对一的关系......
class Registry < ActiveRecord::Base
has_many :user_registries
attr_accessible :logo, :name
has_attached_file :logo
end
和 user_registries...
class UserRegistry < ActiveRecord::Base
belongs_to :page
has_one :registry
attr_accessible :page_id, :registry_id, :url
end
我正在尝试在表单中显示名称或徽标,如下所示:
.registry
= debug f.object.registry.name
.field
= f.label :title
= f.text_field :title
.field
= f.label :url
= f.text_field :url
.field
= f.hidden_field :_destroy
= link_to_function "remove", "remove_fields(this)"
但我得到一个 SQL 错误,如下所示:
Mysql2::Error: Unknown column 'registries.user_registry_id' in 'where clause': SELECT `registries`.* FROM `registries` WHERE `registries`.`user_registry_id` = 14 LIMIT 1
我的关系没有正确建立吗?