Class: Workarea::Admin::ContentPagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/content_pages_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#destroyObject



36
37
38
39
40
# File 'app/controllers/workarea/admin/content_pages_controller.rb', line 36

def destroy
  @page.destroy
  flash[:success] = t('workarea.admin.content_pages.flash_messages.removed')
  redirect_to content_pages_path
end

#editObject



22
23
24
# File 'app/controllers/workarea/admin/content_pages_controller.rb', line 22

def edit
  @page = Admin::PageViewModel.new(@page)
end

#indexObject



10
11
12
13
14
15
16
# File 'app/controllers/workarea/admin/content_pages_controller.rb', line 10

def index
  search = Search::AdminPages.new(
    params.merge(autocomplete: request.xhr?)
  )

  @search = Admin::SearchViewModel.new(search, view_model_options)
end

#showObject



18
19
20
# File 'app/controllers/workarea/admin/content_pages_controller.rb', line 18

def show
  @page = Admin::PageViewModel.new(@page)
end

#updateObject



26
27
28
29
30
31
32
33
34
# File 'app/controllers/workarea/admin/content_pages_controller.rb', line 26

def update
  if @page.update_attributes(params[:page])
    flash[:success] = t('workarea.admin.content_pages.flash_messages.saved')
    redirect_to content_page_path(@page)
  else
    @page = Admin::PageViewModel.new(@page)
    render :edit, status: :unprocessable_entity
  end
end