Mercurial > zeropaste
diff app/models/paste.rb @ 265:6cca1ab53337
Infinitely better error messages and notice.
author | edogawaconan <me@myconan.net> |
---|---|
date | Wed, 16 Oct 2013 02:56:30 +0900 |
parents | a894d7696b7e |
children | 0bf1d6f75baa |
line wrap: on
line diff
--- a/app/models/paste.rb Wed Oct 16 02:19:36 2013 +0900 +++ b/app/models/paste.rb Wed Oct 16 02:56:30 2013 +0900 @@ -6,7 +6,7 @@ before_validation :set_paste_key before_validation :set_paste_secret validates :paste, :paste_hash, :key, :ip, :presence => true - validates :paste, :length => { :maximum => 1_000_000 } + validates :paste, :length => { :maximum => 1 } def to_param path @@ -22,6 +22,15 @@ end end + def safe_destroy(param_key) + if key == param_key + destroy + else + errors.add(:key, "is invalid") + false + end + end + def path [id, secret.presence].compact.join("-") end