3

我无法调试我收到错误的原因:

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?

Vendor 的每个实例至少有一个标签。

4

1 回答 1

5

明白了,我需要@tags = Vendor.tag_counts_on(:tags)index controller.

于 2010-01-04T20:03:19.533 回答