質問

投稿/インデックスビューにこのコードがあります:

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

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top