+#素材
class ResourcePicture < ActiveRecord::Base
belongs_to :artist
belongs_to :license
has_many :panel_pictures
belongs_to :original_picture
- validates :ext, :presence => true, :length => {:maximum => 4}, :inclusion => {:in => ['png', 'jpeg', 'gif']}\r
+ validates :ext, :presence => true, :length => {:maximum => 4}, :inclusion => {:in => ['png', 'jpeg', 'gif']}
validates :width, :presence => true, :numericality => true, :natural_number => true
validates :height, :presence => true, :numericality => true, :natural_number => true
validates :filesize, :presence => true, :numericality => {:greater_than => 0, :less_than_or_equal_to => 2000000}, :natural_number => true
validates :license_id, :presence => true, :numericality => true, :existence => true
validates :original_picture_id, :presence => true, :numericality => true, :existence => true
validates :artist_name, :presence => true
+ validates :classname, :presence => true, :length => {:maximum => 50}
validates :picture_id, :presence => true, :numericality => true, :existence => true
before_destroy :destroy_with_file
ResourcePicture.count
end
+ def credit_template
+ "#{self.classname.tableize}/credit"
+ end
+
+ def credit_data
+ begin
+ @credit_data = JSON.parse(self.credit) unless @credit_data
+ rescue
+ end
+ @credit_data
+ end
+
def flags
begin
@flags = JSON.parse(self.settings) unless @flags