Question

I can't debug why I am getting an error:

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

I set this class as Taggable:

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

I include the TagsHelper:

module VendorsHelper
  include TagsHelper
end

This is in my View:

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

This is the error that I get:

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?

Each instance of Vendor has at least one Tag.

Was it helpful?

Solution

Got it, I needed to add: @tags = Vendor.tag_counts_on(:tags) in the index controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top