Pregunta

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.

¿Fue útil?

Solución

 <%= 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 = {})
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top