Class: Maglev::Page

Inherits:
ApplicationRecord show all
Includes:
PathConcern, SearchConcern, SectionsConcern, Translatable
Defined in:
app/models/maglev/page.rb

Defined Under Namespace

Modules: PathConcern, SearchConcern

Constant Summary

Constants included from PathConcern

PathConcern::COMMON_ASSOCIATION_PATH_OPTIONS

Instance Method Summary collapse

Methods included from PathConcern

#canonical_path_hash, #current_path, #default_path, #disable_spawn_redirection, #path, #path=, #path_hash, #spawn_redirection_disabled?

Methods included from SectionsConcern

#find_sections_by_type, #prepare_sections, #prepare_sections_translations

Methods included from Translatable

#translate_attr_in, #translations_for

Methods inherited from ApplicationRecord

mysql?

Instance Method Details

#homeObject

scopes ##



35
# File 'app/models/maglev/page.rb', line 35

scope :home, ->(locale = nil) { by_path('index', locale) }

#index?Boolean

methods ##

Returns:

  • (Boolean)


47
48
49
# File 'app/models/maglev/page.rb', line 47

def index?
  path == 'index'
end

#static?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/maglev/page.rb', line 51

def static?
  false
end

#titleObject

translations ##



29
# File 'app/models/maglev/page.rb', line 29

translates :title, presence: true

#translate_in(locale, source_locale) ⇒ Object



55
56
57
58
59
# File 'app/models/maglev/page.rb', line 55

def translate_in(locale, source_locale)
  %i[title sections seo_title meta_description og_title og_description og_image_url].each do |attr|
    translate_attr_in(attr, locale, source_locale)
  end
end