handle invalid param gracefully

This commit is contained in:
Sam 2015-05-07 11:06:42 +10:00
parent 8277a586bb
commit d676bbc349

View file

@ -14,7 +14,9 @@ class IncomingLink < ActiveRecord::Base
user_id, host, referer = nil user_id, host, referer = nil
current_user = opts[:current_user] current_user = opts[:current_user]
if username = opts[:username] username = opts[:username]
username = nil unless String === username
if username
u = User.select(:id).find_by(username_lower: username.downcase) u = User.select(:id).find_by(username_lower: username.downcase)
user_id = u.id if u user_id = u.id if u
end end