ruby on rails f.select options with custom attributes

后端 未结 5 1614
一个人的身影
一个人的身影 2020-11-28 01:34

I have a form select statement, like this:

= f.select :country_id, @countries.map{ |c| [c.name, c.id] }

Which results in this code:

5条回答
  •  情深已故
    2020-11-28 01:51

    You could do this as follows:

    = f.select :country_id, @countries.map{ |c| [c.name, c.id, { 'data-currency-code' => c.currency_code} ] }
    

提交回复
热议问题