3

エラーが発生する理由をデバッグできません:

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

このクラスをTaggableとして設定しました。

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?

ベンダーの各インスタンスには、少なくとも1つのタグがあります。

4

1 に答える 1

5

了解しました。次を追加する必要が@tags = Vendor.tag_counts_on(:tags)ありましたindex controller

于 2010-01-04T20:03:19.533 に答える