Boss Nass
Boss Nass

Reputation: 3522

Radio buttons from a collection

I am trying to return a set of radio buttons based on a collection within my database but I am not having much luck.

View code

- @merchant_type.each do |mt|
    = form.radio_button mt, mt.name

Controller Code

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

Error

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'

Upvotes: 0

Views: 1186

Answers (1)

Jayaprakash
Jayaprakash

Reputation: 1403

Try this

- @merchant_type.each do |mt|
    = form.radio_button :merchant_type, mt.name

Upvotes: 1

Related Questions