Frage

Ich kann nicht debuggen, warum ich eine Störung erhalte:

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

Ich habe diese Klasse als markierbare:

class Vendor < ActiveRecord::Base
  acts_as_taggable_on :tags, :competitors

I gehören die TagsHelper:

module VendorsHelper
  include TagsHelper
end

Dies ist meine Ansicht:

 <% 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 %>

Das ist der Fehler, den ich bekommen:

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?

Jede Instanz Vendor mindestens einen Tag.

War es hilfreich?

Lösung

Verstanden, musste ich hinzufügen:. @tags = Vendor.tag_counts_on(:tags) im index controller

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top