1 class Comic < ActiveRecord::Base
2 has_many :panels, :dependent => :destroy
5 class NotZeroValidator < ActiveModel::EachValidator
\r
6 def validate_each(record, attribute, value)
\r
7 record.errors[attribute] << (options[:message] || "is zero") if value == 0
\r
11 validates :title, :presence => true, :length => {:maximum => 100}
\r
12 validates :width, :presence => true, :numericality => true, :not_zero => true
13 validates :height, :presence => true, :numericality => true, :not_zero => true
14 validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0...4}
15 validates :editable, :presence => true, :numericality => true, :inclusion => {:in => 0...4}
22 self.visible = 0 if self.visible.blank?
23 self.editable= 0 if self.editable.blank?
27 return false unless author
28 self.author_id == author.id
32 editable == 1 ? 'O' : 'X'
36 visible == 1 ? 'O' : 'X'