Class: Maglev::Api::PagesController

Inherits:
Maglev::ApiController show all
Defined in:
app/controllers/maglev/api/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
# File 'app/controllers/maglev/api/pages_controller.rb', line 17

def create
  page = persist!(resources.new)
  head :created, location: api_page_path(page)
end

#destroyObject



22
23
24
25
# File 'app/controllers/maglev/api/pages_controller.rb', line 22

def destroy
  resources.destroy(params[:id])
  head :no_content
end

#indexObject



6
7
8
9
# File 'app/controllers/maglev/api/pages_controller.rb', line 6

def index
  @pages = services.search_pages.call(q: params[:q], content_locale: content_locale,
                                      default_locale: default_content_locale)
end

#showObject



11
12
13
14
15
# File 'app/controllers/maglev/api/pages_controller.rb', line 11

def show
  @page = services.search_pages.call(id: params[:id], content_locale: content_locale,
                                     default_locale: default_content_locale)
  head :not_found if @page.nil?
end

#updateObject



27
28
29
30
31
# File 'app/controllers/maglev/api/pages_controller.rb', line 27

def update
  page = resources.find(params[:id])
  persist!(page)
  head :ok, page_lock_version: page.lock_version
end