Sha256: 582a89cb2ad78b8e6c890262c9aaaabf1aec6a0467c5218d9830730d7b7caa5b

Contents?: true

Size: 747 Bytes

Versions: 7

Compression:

Stored size: 747 Bytes

Contents

module HowTo
  class Section < ActiveRecord::Base
    validates :name, :presence => true

    translates :name
    acts_as_nested_set

    has_many :contents, :dependent => :destroy

    include HowTo::TranslationUtil
    allow_multi_locales_edit(*I18n.available_locales)

    scope :active, -> { where(active: true) }
    scope :roots_only, -> { where(:parent_id => nil) }
    scope :without, ->(id) { where("id <> ? ", id) if id.present? }
    scope :with_content, -> { where("contents_count > 0") }
    scope :ordered, -> { order("position ASC") }

    # class Translation
    #   attr_accessible :locale, :name
    # end

    private

    def mass_assignment_authorizer(role = :default)
      self.class.protected_attributes
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
how_to-2.0.4 app/models/how_to/section.rb
how_to-2.0.3 app/models/how_to/section.rb
how_to-2.0.2 app/models/how_to/section.rb
how_to-2.0.1 app/models/how_to/section.rb
how_to-2.0.0 app/models/how_to/section.rb
how_to-1.0.3 app/models/how_to/section.rb
how_to-1.0.2 app/models/how_to/section.rb