<span class="icon-stack">
  <i class="icon-circle  icon-stack-base"></i>
  <i class="icon-info  icon-light"></i>
</span>
<p class="info"><%=t('categories.info')%></p>
<div class="actions-clone">
  <% categories = subject_categories(current_subject, {:scope => :me, :limit => 0}) %>
  <% categories_array = categories.map { |category| [category.title, category.id] } %>
  <%= select_tag(:category_id, options_for_select(categories_array)) %>


  <%= form_for categories.first, :remote => true do |f| %>
    <%= f.hidden_field :item_type, :value => item.class.to_s %>
    <%= f.hidden_field :item_id, :value => item.id %>
    <a class="btn btn_cancel"><%=t('cancel')%></a>
    <%= f.submit t('button.save')%>
  <% end %>

  <script>
    $("#category_id").change(function() {
      $(".edit_category").attr("action", "/categories/" + $(this).val());
      $(".edit_category").attr("id", "edit_category_" + $(this).val());
    });
  </script>
</div>
<span class="icon-stack">
  <i class="icon-circle  icon-stack-base"></i>
  <i class="icon-info  icon-light"></i>
</span>
<p class="info"><%=t('categories.info')%></p>
<div class="actions-clone">
  <% categories = subject_categories(current_subject, {:scope => :me, :limit => 0}) %>

  <% if categories.empty? %>
    <a class="btn btn-primary" href="#AddCategory" data-toggle="modal"><%=t('categories.actions.add')%></a>
  <% else %>
    <% categories_array = categories.map { |category| [category.title, category.id] } %>
    <% more_options = options_for_select(["-----", [t('categories.actions.add')]], disabled: "-----") %>
    <%= select_tag(:category_id, options_for_select(categories_array) + more_options)%>

    <%= form_for categories.first, :remote => true do |f| %>
      <%= f.hidden_field :item_type, :value => item.class.to_s %>
      <%= f.hidden_field :item_id, :value => item.id %>
      <a class="btn btn_cancel"><%=t('cancel')%></a>
      <%= f.submit t('button.save')%>
    <% end %>

    <script>
      $("#category_id").change(function() {
        //If Add a category is selected
        if ($(this).val() == "<%= t('categories.actions.add') %>") {
          //Show Add category partial
          $('#AddCategory').modal();
        } else {
          $(".edit_category").attr("action", "/categories/" + $(this).val());
          $(".edit_category").attr("id", "edit_category_" + $(this).val());
        }
      });
    </script>
  <% end %>


</div>
Add category option if no categories
Add category option if no categories
