Sha256: b723f49f70ad9948ee354da99b82f9ebc8081632461d642326a3eda581b5b728

Contents?: true

Size: 836 Bytes

Versions: 65

Compression:

Stored size: 836 Bytes

Contents

class CamaleonCms::Widget::Sidebar < CamaleonCms::TermTaxonomy
  default_scope { where(taxonomy: :sidebar) }
  has_many :metas, ->{ where(object_class: 'Widget::Sidebar')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :destroy
  has_many :assigned, foreign_key: :post_parent, dependent: :destroy
  belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id

  #scopes
  scope :default_sidebar, -> { where(:slug => 'default-sidebar') }
  scope :all_sidebar, -> { where("slug != 'default-sidebar'") }

  # assign the widget into this sidebar
  # widget: string(slug)/object
  # data: {title, content}
  def add_widget(widget, data = {})
    widget = self.site.widgets.where(slug: widget).first if widget.is_a?(String)
    data[:widget_id] = widget.id
    self.assigned.create(data)
  end

end

Version data entries

65 entries across 65 versions & 2 rubygems

Version Path
camaleon_cms-2.5.3.1 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.5.3 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.5.2 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms_rails6-2.5.0 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.5.1 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.5.0 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.9 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.8 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.7 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.6 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.5 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.4 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.3 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.2 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.1 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.6.0 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.14 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.13 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.12 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.11 app/models/camaleon_cms/widget/sidebar.rb