More idiomatic approach to finding drafts
This commit is contained in:
parent
86244e3a4b
commit
2beaeed36d
|
@ -29,10 +29,12 @@ class Draft < ActiveRecord::Base
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def self.find_draft(user,key)
|
def self.find_draft(user, key)
|
||||||
user_id = user
|
if user.is_a?(User)
|
||||||
user_id = user.id if User === user
|
find_by(user_id: user.id, draft_key: key)
|
||||||
Draft.where(user_id: user_id, draft_key: key).first
|
else
|
||||||
|
find_by(user_id: user, draft_key: key)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue