문제

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