-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< br /> 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 the tag cloud from the index view to the application layout, but I don’t know how to call the controller action method from there.
In addition, I have a question, this Is MVC safe? Please give me any suggestions.
I am using the gem’act-as-taggable-on’
def tag_cloud
@tags ||= Post.tag_counts_on(:tags)
end
Go to ApplicationHelper and then you can use it <%= tag_cloud%> in your application layout.
In my posts/index view There is this code:
-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:
< pre>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 the tag cloud from the index view to the application layout, but I don’t know how to call the controller action method from there.
Also, I have a question about this MVC is it safe? Please give me any suggestions.
I am using the gem’act-as-taggable-on’
Code for moving tag_cloude
def tag_cloud
@tags ||= Post.tag_counts_on(:tags)
end
Go to ApplicationHelper and then you can Use it <%= tag_cloud%> in your application layout.