handle invalid param gracefully

This commit is contained in:
Sam 2015-05-07 11:06:42 +10:00
parent 8277a586bb
commit d676bbc349
1 changed files with 3 additions and 1 deletions

View File

@ -14,7 +14,9 @@ class IncomingLink < ActiveRecord::Base
user_id, host, referer = nil
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)
user_id = u.id if u
end