> Yep, but you can't have it both ways.  If you have users JoeBob and  
> JOEbob and the browser requests "JoEbOb", which record do you return?  
> You have to pick one and half the time you'll pick wrong.
>
> What you could do is require uniqueness on username's regardless of  
> caps, but let them use caps to make username's easier to read... then  
> you wouldn't have the conflict.

That's what I was doing
validates_uniqueness_of :username, :case_sensitive => false
which prevents JoeBob and JOEbob from signing up.  And that might be
the way it has to stay,

But, this got me thinking:
User.find_by_username(params[:user].downcase)
This will find the correct person in the db and return no errors, no
matter how many capitalizations someone uses in the URL.  But this
only works if the original user signed up with no capitalizations in
his/her name.

So, if the user signed up as joebob, then JOEbob, JoEbOb, or any other
variation will return the correct result, AND it will leave the URL
just as the user entered it, caps and all.

But, this doesn't work if the user originally signed up with caps in
his name.  So, what if I were to create an index in the table for the
usernames and pass in the option downcase.  I think it would work
perfectly then, but I'm not sure if this can be done?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to