belongs_to :license_group
belongs_to :system_picture
- validates :license_group_id, :presence => true, :numericality => true, :existence => true
+ validates :license_group_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :name, :presence => true, :length => {:maximum => 50}
validates :caption, :presence => true, :length => {:maximum => 30}
- validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => true #{:allow_blank => true}
- validates :system_picture_id, :presence => true, :numericality => true, :existence => true
+ validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
+ validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
def supply_default
end
def self.store name, attr
r = License.replace_system_picture attr
+ attr['credit_pictures'] = attr['credit_pictures'].to_json
l = License.modify_object name, attr
if r == false
l.errors.add :base, 'system picture can not create'
res
end
+ def credit_pictures_attr
+ return @credit_pictures_attr if @credit_pictures_attr
+ begin
+ @credit_pictures_attr = JSON.parse(self.credit_pictures)
+ rescue
+ end
+ @credit_pictures_attr = {} unless @credit_pictures_attr
+ @credit_pictures_attr
+ end
+
end