Sha256: 900d3473e1dfce65fd52ca3320588bccd9adfecbc94321fb5407e324e3d9cf3a

Contents?: true

Size: 791 Bytes

Versions: 40

Compression:

Stored size: 791 Bytes

Contents

class CmsBlock < ActiveRecord::Base
  
  # -- Relationships --------------------------------------------------------
  belongs_to :cms_page
  
  # -- Validations ----------------------------------------------------------
  validates :label,
    :presence   => true,
    :uniqueness => { :scope => :cms_page_id }
  
  # -- Class Methods --------------------------------------------------------
  def self.initialize_or_find(cms_page, label)
    if block = cms_page.cms_blocks.detect{ |b| b.label == label.to_s }
      self.new(
        :record_id  => block.id,
        :cms_page   => cms_page,
        :label      => block.label,
        :content    => block.content
      )
    else
      self.new(
        :label    => label.to_s,
        :cms_page => cms_page
      )
    end
  end
  
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
comfortable_mexican_sofa-1.0.51 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.50 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.49 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.48 app/models/cms_block.rb
lucy_cms-0.0.6 app/models/cms_block.rb
lucy_cms-0.0.5 app/models/cms_block.rb
lucy_cms-0.0.4 app/models/cms_block.rb
lucy_cms-0.0.3 app/models/cms_block.rb
lucy_cms-0.0.2 app/models/cms_block.rb
lucy_cms-0.0.1 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.47 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.46 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.45 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.44 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.43 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.42 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.41 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.40 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.39 app/models/cms_block.rb
comfortable_mexican_sofa-1.0.38 app/models/cms_block.rb