views:

177

answers:

1

I'm using acts_as_taggable_on_steroids plugin with rails 2.3.5 to build a tag cloud and I'm unfamiliar with the syntax of their view loop. I couldn't find any ruby doc explaining that loop either.

When I run the code below I get this "no block given" error.

LocalJumpError in Tags#index
Showing app/views/tags/index.html.erb where line #10 raised:
no block given

I thought I needed to add the tag_cloud method to my routes.rb file but that didn't solve the problem.

Controller:

class PostController < ApplicationController
    def tag_cloud
      @tags = Post.tag_counts
    end
  end

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

Looks like the TagsHelper in the plugin wasn't being included despite me including it in ApplicationHelper.

I just copied the function tag_cloud into my TagsHelper and it worked.

Why I didn't understand that loop was because it's a method call with a loop chained to it. Think of it like this

<% tag_cloud( @tags, %w(css1 css2 css3 css4) ) do |tag, css_class| %>
  <%= link_to tag.name, tags_path(tag), :class => css_class %>
<% end %>
jspooner