Skip to content

Instantly share code, notes, and snippets.

@cowgill
Created December 30, 2013 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowgill/8184223 to your computer and use it in GitHub Desktop.
Save cowgill/8184223 to your computer and use it in GitHub Desktop.
Trying to get closure_tree to render a drop down with categories and sub-categories nested. Neither of the two items work.
<%= form_for(@item, html: {class: 'form_auth'}) do |f| %>
<% if @item.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
<ul>
<% @item.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<%= f.label :name %>
<%= f.text_field :name, :autofocus => true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :category %>
<%= select_tag :category_id, options_for_select(Category.hash_tree) %>
<%= f.collection_select(:category_id, Category.hash_tree, :id, :name, {include_blank: "Select one"}, {class: "form-control"}) %>
</div>
<div class="form-group">
<%= f.label :description %>
<%= f.text_area :description, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :meta_title %>
<%= f.text_field :meta_title, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :meta_description %>
<%= f.text_area :meta_description, class: "form-control" %>
</div>
<div class="actions">
<%= f.submit "Submit Item", class: "btn btn-large btn-primary" %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment