كيف يمكنني إنشاء سحابة علامة في Acts_as_taggable_on؟
-
18-09-2019 - |
سؤال
لا أستطيع تصحيح السبب في أنني أحصل على خطأ:
class VendorsController < ApplicationController
def tag_cloud
@tags = Vendor.tag_counts_on(:tags)
end
قمت بتعيين هذه الفئة كما TIGGALE:
class Vendor < ActiveRecord::Base
acts_as_taggable_on :tags, :competitors
أقوم بتضمين Tagshelper:
module VendorsHelper
include TagsHelper
end
هذا في رأيي:
<% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %>
<%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %>
<% end %>
هذا هو الخطأ الذي أحصل عليه:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
كل مثيل من البائع لديه علامة واحدة على الأقل.
المحلول
حصلت عليه، كنت بحاجة لإضافة: @tags = Vendor.tag_counts_on(:tags)
في ال index controller
.
لا تنتمي إلى StackOverflow