In my app I have categories
and labels
they both belongs to products
In the admin panel the user can add products, and create labels and categories and then assign categories and labels to products.
When I create labels the names are displaying correctly in the Label Panel( see photo)
The Problem is that the labels name aren't displaying right when they are assign to products(see photo below) but the categories names are displaying. This is strange because both columns have the same setup.
And in the Admin products panel
the labels are displaying with numbers Label#1``Label#2
etc (see photo below)
And in the _navbar.html.erb
I have this code to display Both Categories and Labels... and it is displaying correctly in there.
<ul class="dropdown-menu" role="menu">
<% @categories.each do |category| %>
<li><%= link_to category.name, category %></li>
<% end %>
</ul>
</li>
<li class="dropdown full-width">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown">
Labels
</a>
<ul class="dropdown-menu" role="menu">
<% @labels.each do |label| %>
<li><%= link_to label.label_name, label %></li>
<% end %>
</ul>
</li>
Am I missing something here? I can't see why the labels aren't displaying correctly.
Have anyone had the same or similar problem with active admin?
Can anyone take a look at this?
Thanks in advance
This is the app/admin/category.rb
ActiveAdmin.register Category do
permit_params :name
end
In the app/admin/label.rb
there is this code:
ActiveAdmin.register Label do
permit_params :label_name
end
And in the app/admin/product.rb
ActiveAdmin.register Product do
permit_params :title, :description, :image, :price_usd, :price_isl, :category_id, :label_id
index do
column :title
column :category
column :label
column :created_at
column :price_isl, :sortable => :price_isl do |product|
number_to_currency product.price_isl
end
column :price_usd, :sortable => :price_usd do |product|
number_to_currency product.price_usd
end
actions
end
end
Then here are parts of the Schema.rb
create_table "labels", force: :cascade do |t|
t.string "label_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "categories", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end