0
我试图根据数据库中的集合返回一组单选按钮,但我没有多少运气。集合中的单选按钮
查看代码
- @merchant_type.each do |mt|
= form.radio_button mt, mt.name
控制器代码
def new
@merchant_type = MerchantType.all
@merchant = Merchant.new
@states = State.form_selector
@products = Product.order(:name => 'asc')
@properties = Property.where(property_set_id: 1)
@merchant.trading_hours.build
end
错误
ActionView::Template::Error (undefined method `#<MerchantType:0x007fd16b55ac50>' for #<Merchant:0x007fd16c481468>):
6: p
7: b Type
8: - @merchant_type.each do |mt|
9: = form.radio_button mt, mt.name
app/views/admin/merchants/_type.html.slim:9:in `block in _app_views_admin_merchants__type_html_slim___3402008222164699688_70268702644260'
app/views/admin/merchants/_type.html.slim:8:in `_app_views_admin_merchants__type_html_slim___3402008222164699688_70268702644260'
'MerchantType.all'显然是触发了错误......但我无法推断出可能触发错误的原因。我假设你能够在你的滑轨控制台中运行'MerchantType.all'吗? – angkiki
你试过这个“form.radio_button:merchant_type,mt.name”吗? – Jayaprakash
@Jayaprakash不,我没有,似乎已经工作 –