Mercurial > zeropaste
comparison app/models/paste.rb @ 247:9aa67da381b0
Make sure to split a string.
| author | edogawaconan <me@myconan.net> |
|---|---|
| date | Thu, 10 Oct 2013 04:25:07 +0000 |
| parents | 1c750d3cde1b |
| children | a894d7696b7e |
comparison
equal
deleted
inserted
replaced
| 246:8ab17063419f | 247:9aa67da381b0 |
|---|---|
| 11 def to_param | 11 def to_param |
| 12 path | 12 path |
| 13 end | 13 end |
| 14 | 14 |
| 15 def self.safe_find(raw_id) | 15 def self.safe_find(raw_id) |
| 16 id, secret = raw_id.split("-") | 16 id, secret = raw_id.to_s.split("-") |
| 17 return unless id.to_i.to_s == id | 17 return unless id.to_i.to_s == id |
| 18 begin | 18 begin |
| 19 self.where(secret: secret).find(id) | 19 self.where(secret: secret).find(id) |
| 20 rescue ActiveRecord::RecordNotFound | 20 rescue ActiveRecord::RecordNotFound |
| 21 nil | 21 nil |
