投稿/インデックスビューに次のコードがあります:
-tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class|
= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class
これは私のコントローラーです:
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
タグクラウドをインデックスビューからアプリケーションレイアウトに移動したいのですが、そこからコントローラーアクションメソッドを呼び出す方法がわかりません。
また、私は疑問ですが、このMVCは安全ですか?アドバイスをお願いします。
使っていますgem 'acts-as-taggable-on'