annotate app/models/paste.rb @ 10:56c17679105b

Moar pastes.
author Edho Arief <edho@myconan.net>
date Sun, 26 Aug 2012 11:59:55 -0700
parents 42de15334db1
children 032686a0c995
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
1 class Paste < ActiveRecord::Base
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
2 attr_accessible :paste
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
3 before_validation :set_paste_hash
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
4 validates :paste, :paste_hash, :ip, :presence => true
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
5 validates :paste, :length => { :maximum => 1_000_000 }
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
6
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
7 def set_paste_hash
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
8 self.paste_hash = Digest::SHA512.hexdigest(paste)
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
9 end
42de15334db1 Added the pastes.
Edho Arief <edho@myconan.net>
parents:
diff changeset
10 end