Class: Maglev::PagePath
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Maglev::PagePath
- Defined in:
- app/models/maglev/page_path.rb
Class Method Summary collapse
-
.build_hash(page_id = nil) ⇒ Object
class methods ##.
Instance Method Summary collapse
-
#canonical ⇒ Object
scopes ##.
-
#page ⇒ Object
associations ##.
-
#self ⇒ Object
callbacks ##.
-
#value ⇒ Object
validations ##.
Class Method Details
.build_hash(page_id = nil) ⇒ Object
class methods ##
26 27 28 29 |
# File 'app/models/maglev/page_path.rb', line 26 def self.build_hash(page_id = nil) query = page_id ? where(maglev_page_id: page_id) : all query.canonical.pluck(:locale, :value).to_h end |
Instance Method Details
#canonical ⇒ Object
scopes ##
9 |
# File 'app/models/maglev/page_path.rb', line 9 scope :canonical, -> { where(canonical: true) } |
#page ⇒ Object
associations ##
6 |
# File 'app/models/maglev/page_path.rb', line 6 belongs_to :page, class_name: 'Maglev::Page', foreign_key: 'maglev_page_id', inverse_of: :paths |
#self ⇒ Object
callbacks ##
19 |
# File 'app/models/maglev/page_path.rb', line 19 after_initialize -> { self.locale ||= Maglev::I18n.current_locale } |