我使用simple_form作爲我的Rails項目中的表單生成器,使用RethinkDB作爲數據庫和NoBrainer ORM。我建立了模型以包含它們之間的關係,但是當試圖爲關聯生成選擇下拉列表時,出現錯誤關聯:沒有找到貨幣。我哪裏錯了?Rails simple_form與NoBrainer和RethinkDB的關聯
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
所以我看到NoBrainer還不支持Reflection,這就是爲什麼f.association方法還沒有工作。然而,有一個拉取請求包含反射支持。 – BrazenBraden