我不能调试为什么我收到一个错误:

class VendorsController < ApplicationController
  def tag_cloud
    @tags = Vendor.tag_counts_on(:tags)
  end

我设置这个类作为可加标签:

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top