It shouldn't be case-sensitive.
User.find_by_username(params[:user_id]) should return the user.
It shouldn't be case-sensitive.
User.find_by_username(params[:user_id]) should return the user.
I know this isn't exactly what you want, but I find it a nice go
between often times, and you don't need to hack everything up to make
it work.
I would pass the id as well as the username. You can do that by
setting the method to_param in the model file for whatever model you
want to preform this on, in your case, the user model.
# user.rb
def to_param "#{id}-#{username}" end
The cool thing about to_param, is that you don't have to change any of
your link_to methods, or .find methods normally.
If you did this in the view: # index.rhtml link_to @user.username, {:action => "show", :id => @user}
or if you are using restful routes: link_to @user.username, user_path(@user)
Looks pretty normal right? The cool thing is that even though it
looks that normal, when you hit the link in the browser, the url will
look like this:
"/users/12-billybob"
And in your controllers, you can do a very basic: User.find(params[:id])
If you still want to use only the username, there are also ways to do
that, but they are not as easy, lemme know.