Skip to content

Instantly share code, notes, and snippets.

@axilaris
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save axilaris/9597320 to your computer and use it in GitHub Desktop.

Select an option

Save axilaris/9597320 to your computer and use it in GitHub Desktop.
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<script>
$(document).ready(function() {
$('select#option').select2();
});
</script>
<br><br>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
<%= select_tag(:option,
options_for_select([['All', 1], ['Co', 2], ['Bought', 3], ['View', 4], ['Top API', 5]] )) %>
</div>
<div class="actions">
<%= f.submit :class => "btn btn-primary" %>
</div>
<% end %>
*= require bootstrap
*= require_tree .
*= require_self
*= require select2
*= require select2-bootstrap
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
//= require select2
gem 'bootstrap-sass'
gem 'select2-rails'
@axilaris
Copy link
Copy Markdown
Author

the problem, noticed the f.text_field :name not aligned with select_tag(:option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment