if(Rails.application.routes.recognize_path('nickname') rescue nil)
else
end
UPD:
If any path seems to be recognized recognize_path, then you have something like:
get ':nick' => 'user#show'
routes.rb, , . , . :
class NickMustExistConstraint
def self.matches?(req)
req.original_url =~ %r[//.*?/(.*)]
User.find_by_nick $1
end
end
get ':nick' => 'users#show', constraints: NickMustExistConstraint
, , jdoe, /jdoe. rroe, /rroe, .
, , :
def to_param
nick
end
resources :users, path: 'u'
/u/jdoe ( REST).
, User.find_by_nick! params[:id] (, params[:id], , , ).