Sha256: f7770e11288f9cf284e35e27d7636596b2e0bd0186226a144514a17a7f571ae4
Contents?: true
Size: 1.21 KB
Versions: 31
Compression:
Stored size: 1.21 KB
Contents
class Caboose::PageBlockFieldValue < ActiveRecord::Base self.table_name = "page_block_field_values" belongs_to :page_block belongs_to :page_block_field has_attached_file :file, :path => '/uploads/:id.:extension' do_not_validate_attachment_file_type :file has_attached_file :image, :path => 'uploads/:id_:style.:extension', :styles => { :tiny => '160x120>', :thumb => '400x300>', :large => '640x480>' } do_not_validate_attachment_file_type :image attr_accessible :id, :page_block_id, :page_block_field_id, :value after_initialize do |fv| # Do whatever we need to do to set the value to be correct for the field type we have. # Most field types are fine with the raw value in the database case fv.page_block_field.field_type when 'checkbox' then fv.value = (fv.value == 1 || fv.value == '1' || fv.value == true ? true : false) end end before_save :caste_value def caste_value case self.page_block_field.field_type when 'checkbox' if self.value.nil? then self.value = false else self.value = (self.value == 1 || self.value == '1' || self.value == true ? 1 : 0) end end end end
Version data entries
31 entries across 31 versions & 1 rubygems