Class: Alchemy::JsonApi::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/alchemy/json_api/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject


8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/alchemy/json_api/pages_controller.rb', line 8

def index
  allowed = [:page_layout]

  jsonapi_filter(page_scope, allowed) do |filtered|
    # decorate with our page model that has a eager loaded elements collection
    pages = filtered.result.map { |p| Alchemy::JsonApi::Page.new(p) }
    jsonapi_paginate(pages) do |paginated|
      render jsonapi: paginated
    end
  end
end

#showObject


20
21
22
# File 'app/controllers/alchemy/json_api/pages_controller.rb', line 20

def show
  render jsonapi: Alchemy::JsonApi::Page.new(@page)
end