I have a Rails 3 application set to use HTML5. I previously programmed a select tag to display some values from an active record query. Now when I run the application the default display is being set to none though I do not开发者_如何学Python have that style attribute set in any of the application stylesheets. Even when I use in-line styling such as
<div id="models">
<select style="display:block;">
<% @models.each do |model| %>
<option value="<%= model.id %>" ><%= model.name %></option>
<% end %>
</select>
</div>
the element's style attribute is still being set to "display: none;".
Do anyone have any suggestions?
I would recommend trying collection_select, something like:
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
e.g.
collection_select(:model, :name, Model.all, :id, :name, {:prompt=>true}, {:class=>'my-class'})
and set my-class in your stylesheet.
精彩评论