Class: Kuhsaft::Cms::PagesController

Inherits:
AdminController show all
Defined in:
app/controllers/kuhsaft/cms/pages_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#set_content_locale

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 20

def create
  @page = Kuhsaft::Page.create params[:page]

  if @page.valid?
    respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
  else
    render 'new'
  end
end

#destroyObject



49
50
51
52
53
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 49

def destroy
  @page = Kuhsaft::Page.find(params[:id])
  @page.destroy
  redirect_to kuhsaft.cms_pages_path
end

#editObject



30
31
32
33
34
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 30

def edit
  @page = Kuhsaft::Page.find(params[:id])
  @page.published ||= Kuhsaft::PublishState::UNPUBLISHED
  respond_with @page
end

#indexObject



4
5
6
7
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 4

def index
  @pages = Kuhsaft::Page.roots
  respond_with @pages
end

#newObject



14
15
16
17
18
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 14

def new
  @page = Kuhsaft::Page.new
  @page.published ||= Kuhsaft::PublishState::UNPUBLISHED
  respond_with @page
end

#showObject



9
10
11
12
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 9

def show
  @page = Kuhsaft::Page.find(params[:id])
  respond_with @page
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 36

def update
  @page = Kuhsaft::Page.find(params[:id])
  @page.update_attributes(params[:page]) if params[:page].present?
  # TODO: refactor 'reposition' as a page attribute, so it can be set through update_attributes
  @page.reposition params[:reposition] if params[:reposition].present? || params.key?(:reposition)

  if params[:add_page_part].present?
    @page.bricks << params[:page][:page_part_type].constantize.new
  end

  respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
end