How to solve this tagging system routing issue

I have a tag resource in routes.rb: resources :tags as well as a tag link code snippet: get 'tags/:tag', to: 'users#index', as: :tag.

The tag link code snippet allows me to click on a tag link and be routed to the user index page with a list of all users who have been tagged with that tag. The link is of the form http://localhost:3000/tags/{tag_name}

Unfortunately these two ideas are clashing because when I try to add a new tag via the tag resource, the link generated is http://localhost:3000/tags/new. Which leads to ambiguity because "new" can be either an action or a tag name.

I'm a rails beginner, any ideas on how to solve this? Most of the code I'm using is from the railscast


Try this In your UsersController

def index
  @users = User.all
  @users = @users.where(tag: params[:tag]) if params[:tag]

Your url


Your view

link_to 'Your tag', "#{users_path}?tag=your_tag"

You could try FriendlyId gem ( and use show action to redirect to users controller.

Need Your Help

Base64 decode Stuck

java android

i need to convert a base64 value into string array so simply i have write this :

Memory explosion with boolean indexing in Pandas

python pandas machine-learning sparse-matrix pytables

I am working with a very large data series of floats in Pandas 12.0. What I am trying to do is set extreme outliers to NaNs in this series, which represents a standardized feature vector (mean is 0...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.