Class: Comable::Admin::PagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/admin/pages_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #respond_to_export_with

Instance Method Details

#createObject



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

def create
  @page = Comable::Page.new(page_params)
  @page.slug = @page.normalize_slug(page_params[:slug])

  if @page.save
    redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
  else
    render :new
  end
end

#destroyObject



47
48
49
50
# File 'app/controllers/comable/admin/pages_controller.rb', line 47

def destroy
  @page.destroy
  redirect_to comable.admin_pages_path, notice: Comable.t('successful')
end

#editObject



21
22
23
# File 'app/controllers/comable/admin/pages_controller.rb', line 21

def edit
  set_preview_session
end

#indexObject



8
9
10
11
# File 'app/controllers/comable/admin/pages_controller.rb', line 8

def index
  @q = Comable::Page.ransack(params[:q])
  @pages = @q.result.accessible_by(current_ability).by_newest
end

#newObject



18
19
# File 'app/controllers/comable/admin/pages_controller.rb', line 18

def new
end

#showObject



13
14
15
16
# File 'app/controllers/comable/admin/pages_controller.rb', line 13

def show
  edit
  render :edit
end

#updateObject



36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/comable/admin/pages_controller.rb', line 36

def update
  @page.attributes = page_params
  @page.slug = @page.normalize_slug(page_params[:slug])

  if @page.save
    redirect_to comable.admin_page_path(@page), notice: Comable.t('successful')
  else
    render :edit
  end
end