Case sensitive url and link_to... help

Hi, after saying this you will hate me, but i've changed an url which takes not the id but the nick. Something like /users/mix/comments everything works fine, just for a "little" problem, when i create the link with link_to or the paginate method it lowercase the controller string, so if i pass it something like :controller => "/users/#{@user.nick}/comments", :action => :index it will lowercase the nick, and if the nick is eg MiX it won't find any user with mix. How can i solve this with have the nick as is? with link_to it can be solved without pass {:controller.... } but "/users/#{@user.nick}/comments", it works, but the problem stays with the paginate url, it doesn't accept that Or another solution would be accept any kind of nick case insensitive, but i think that this would charge more the search in the db, and anyway it's better to show the nick as the user has written it Thanks

Why are you doing this:

:controller => "/users/#{@user.nick}/comments", :action => :index

I don't understand... you have a controller (or namespace) named for each user!? I suspect that's just an error in your question...

I'm surprised that it would be changing the case of your user.nick, but if there is in fact a problem with that, you could write your own find_by_insensitive_nick method to work around that.

Have you tried using to_param for this?

class User   def to_param     nick   end end

Then, if you're using map.resources for the route:

<%= link_to user_comments_path(@user) %>

Or else:

<%= link_to :controller => 'comments', :user_id => @user, :action => 'index' %>

HTH, --Andrew Vit

If you use MySQL you can simply set the collation of the username field to utf8_general_ci (ci = case insensitive) for the same result.