AnthonyGalli.com
AnthonyGalli.com

Reputation: 2866

How to only "link_to" user's tags?

I have this tag_cloud

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

Right now if I click on "run" in my tag_cloud I will be redirected to:

http://www.personalcontrolcenter.com/tags/run

where it then lists out all the tags with "run", including those from other users. How can we only list out the tags from the current user?

routes.rb get 'tags/:tag', to: 'pages#home', as: :tag

I'm using the acts-as-taggable-gem. Thanks for your time!

Upvotes: 0

Views: 25

Answers (1)

Bruno E.
Bruno E.

Reputation: 1424

The route you're using via tag_path in link_to sends the tag to PagesController#home. If you only want to show the tags of current user you should only load those in that controller action.

Upvotes: 1

Related Questions