我在 rails 项目中使用 simple_form 作为我的表单构建器,使用 RethinkDB 作为数据库和 NoBrainer ORM。我已经设置了模型以包含它们之间的关系,但是在尝试为关联生成选择下拉列表时,我收到错误Association :currency not found。我哪里错了?
class Country
include NoBrainer::Document
belongs_to :currency
field :name, type: String
field :nationality, type: String
end
class Currency
include NoBrainer::Document
has_many :countries
field :name, type: String
field :code, type: String
field :symbol, type: String
end
= simple_form_for @country do |f|
= f.input :name, placeholder: 'e.g. Namibia', label: 'Country'
= f.input :nationality, placeholder: 'e.g. Namibian', label: 'Nationality'
= f.association :currency, placeholder: 'Please select one', label: 'Currency', label_method: :code
= f.button :submit