Class: Alchemy::EagerLoading
- Inherits:
-
Object
- Object
- Alchemy::EagerLoading
- Defined in:
- app/models/alchemy/eager_loading.rb
Overview
Eager loading parameters for loading pages
Constant Summary collapse
- PAGE_VERSIONS =
%i[draft_version public_version]
Class Method Summary collapse
-
.page_includes(version: :public_version) ⇒ Array
Eager loading parameters for ActiveRecord::Base.includes.
Class Method Details
.page_includes(version: :public_version) ⇒ Array
Eager loading parameters for ActiveRecord::Base.includes
Pass this to includes
whereever you load an Page
Alchemy::Page.includes(Alchemy::EagerLoading.page_includes).find_by(urlname: "my-page")
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/alchemy/eager_loading.rb', line 17 def page_includes(version: :public_version) raise UnsupportedPageVersion unless version.in? PAGE_VERSIONS [ :tags, { :language => :site, version => { elements: [ :page, :touchable_pages, :tags, { ingredients: :related_object } ] } } ] end |