Domanda

Non riesco a eseguire il debug perché sto ottenendo un errore:

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

Ho impostato questa classe come oggetto di tag:

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

Includo il TagsHelper:

module VendorsHelper
  include TagsHelper
end

Questo è, a mio avviso:

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

Questo è l'errore che ottengo:

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?

Ogni istanza del Venditore ha almeno un Tag.

È stato utile?

Soluzione

Capito, avevo bisogno di aggiungere:. @tags = Vendor.tag_counts_on(:tags) nel index controller

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top