集合中的单选按钮
Radio buttons from a collection
我正在尝试 return 一组基于我数据库中的集合的单选按钮,但我运气不佳。
查看代码
- @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'
试试这个
- @merchant_type.each do |mt|
= form.radio_button :merchant_type, mt.name
我正在尝试 return 一组基于我数据库中的集合的单选按钮,但我运气不佳。
查看代码
- @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'
试试这个
- @merchant_type.each do |mt|
= form.radio_button :merchant_type, mt.name