mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
More idiomatic approach to finding drafts
This commit is contained in:
parent
86244e3a4b
commit
2beaeed36d
1 changed files with 6 additions and 4 deletions
|
@ -29,10 +29,12 @@ class Draft < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def self.find_draft(user,key)
|
||||
user_id = user
|
||||
user_id = user.id if User === user
|
||||
Draft.where(user_id: user_id, draft_key: key).first
|
||||
def self.find_draft(user, key)
|
||||
if user.is_a?(User)
|
||||
find_by(user_id: user.id, draft_key: key)
|
||||
else
|
||||
find_by(user_id: user, draft_key: key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue