diff app/models/paste.rb @ 379:2ad092e60975

[mq]: new-design
author nanaya <me@myconan.net>
date Sun, 07 Jun 2015 02:35:12 +0900
parents 4e6afc8140fb
children 9369ad2f2ce8
line wrap: on
line diff
--- a/app/models/paste.rb	Sat Jun 06 22:36:32 2015 +0900
+++ b/app/models/paste.rb	Sun Jun 07 02:35:12 2015 +0900
@@ -1,5 +1,7 @@
 class Paste < ActiveRecord::Base
   attr_accessor :is_private
+  after_initialize :set_privacy, :if => :new_record?
+
   before_validation :paste_limit
   before_validation :convert_newlines
   before_validation :set_paste_hash
@@ -83,6 +85,10 @@
     errors.add :base, :limit if ip_post_recent_count > 100
   end
 
+  def set_privacy
+    self.is_private ||= "0"
+  end
+
   def self.fix_all
     stats = Hash.new(0)
     all.find_each do |p|