Okay I believe I found the answer. I will post on here in case others have this question. Comment if better way or wrong.
validates :username, :exclusion => { :in => %w(foo bar) }
where foo
and bar
and so on are the words you can't use.
Question
My Rails app uses usernames to get user's profile path
def to_param
username
end
so if a username was licata
, the profile page would be http://localhost:3000/licata
.
Clearly, I need to specify certain words like help
that cannot be used because I have a static page on the app with the route /help
, so a username like this would create a conflict.
What's the most efficient way to do this?
Solution
Okay I believe I found the answer. I will post on here in case others have this question. Comment if better way or wrong.
validates :username, :exclusion => { :in => %w(foo bar) }
where foo
and bar
and so on are the words you can't use.