I'm using

<%= fields_for @reservation do |r| %>
  ....
  <span data-to="date">
    <%= r.select :end_day, options_for_select((0..7).map{|offset| Time.zone.today + offset}) %>
  </span>
  ...
<% end >

to identify the element through the span but I would rather identify the select control itself and apply the data-to to it (not the individual options, though that will be next).

I tried

 <%= r.select :end_day, options_for_select((0..7).map{|offset| Time.zone.today + offset}), data:{to: 'date'} %>

but the attribute didn't show.

有帮助吗?

解决方案

 <%= r.select :end_day, options_for_select((0..7).map{|offset| Time.zone.today + offset}), {}, data: {to: 'date'} %>

Because signature is:

select(method, choices, options = {}, html_options = {})
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top