Question

I have this code in my posts/index 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

This is my controller:

def index
    @posts = Post.page(params[:page]).per(5)
    tag_cloud
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @posts }
    end
end

def tag
  @posts = Post.tagged_with(params[:id]).page(params[:page]).per(5)
  @tags = Post.tag_counts_on(:tags)
  render :template => 'posts/index'
end

def tag_cloud
  @tags ||= Post.tag_counts_on(:tags)
end

I want to move tag cloud from index view to the application layout, but I don't know how to call controller action method from there.

Also, I'm in doubt, is this MVC safe? Any advices please.

I'm using gem 'acts-as-taggable-on'

No correct solution

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