Sha256: 0fb059aef5352563d1801f6ab3fa0a4ef287dd687a4680644160a899b5947b0d

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module Pwb
  class Section < ApplicationRecord
    translates :page_title, fallbacks_for_empty_translations: true
    translates :link_title, fallbacks_for_empty_translations: true
    globalize_accessors locales: [:en, :ca, :es, :fr, :ar, :de, :ru, :pt]

    has_many :contents, foreign_key: "section_key", primary_key: "link_path"

    def as_json(options = nil)
      super({only: [
               :link_key, :link_path, :visible, :sort_order, :id,
               :show_in_top_nav, :show_in_footer, :is_page
             ],
             methods: [:translation_key, :link_title_es, :page_title_es]
             }.merge(options || {}))
    end

    def translation_key
      return "navbar." + self.link_key
    end

    # t.string :link_key
    # t.string :link_path
    # t.integer :sort_order
    # t.boolean :visible
    # t.timestamps null: false
    # add_column :pwb_sections, :flags, :integer, default: 0, index: true, null: false
    # add_column :pwb_sections, :details, :json, default: {}
    # add_column :pwb_sections, :is_page, :boolean, default: false, index: true
    # add_column :pwb_sections, :show_in_top_nav, :boolean, default: false, index: true
    # add_column :pwb_sections, :show_in_footer, :boolean, default: false, index: true
    # add_column :pwb_sections, :key, :string, index: true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pwb-1.0.0 app/models/pwb/section.rb