Sha256: 813f8ede4c1521638cd63945f112668f1f1df67ffaf68471cea2ca5cb22bbec2

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

class Structure < ActiveRecord::Base
  include AbAdmin::Models::Structure

  attr_accessible :structure_type_id, :position_type_id, :parent_id, :title, :redirect_url, :is_visible,
                  :structure_type, :position_type, :slug, :parent

  has_one :picture, -> { where(is_main: true) }, as: :assetable, dependent: :destroy
  has_many :pictures, -> { where(is_main: false) }, as: :assetable, dependent: :destroy

  fileuploads :picture
  translates :title, :redirect_url
  attr_accessible *all_translated_attribute_names

  include AbAdmin::Concerns::AdminAddition
  simple_slug :title

  default_scope -> { nested_set.includes(:translations) }

  def should_generate_new_slug?
    slug.blank? && new_record?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ab_admin-0.6.1 lib/generators/ab_admin/install/templates/models/structure.rb
ab_admin-0.6.0 lib/generators/ab_admin/install/templates/models/structure.rb
ab_admin-0.5.0 lib/generators/ab_admin/install/templates/models/structure.rb
ab_admin-0.4.0 lib/generators/ab_admin/install/templates/models/structure.rb