Class: Admin::PagesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  pages = Cartoset::Config['pages'] || []
  pages << params[:page]
  Cartoset::Config.update :pages => pages

  redirect_to admin_path
end

#editObject



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

def edit
  pages = Cartoset::Config['pages'] || []
  @page = OpenStruct.new pages.select{|p| p['id'].eql?(params[:id])}.first
end

#newObject



4
5
6
7
8
9
10
11
# File 'app/controllers/admin/pages_controller.rb', line 4

def new
  pages = Cartoset::Config['pages'] || []
  last_page_id = pages.sort{|x,y| y['id'] <=> x['id'] }.first['id'] rescue 0

  @page = OpenStruct.new :id => last_page_id.to_i + 1,
                         :title => t('admin.pages.new.new_page'),
                         :permalink => t('admin.pages.new.permalink')
end

#showObject



36
37
38
# File 'app/controllers/admin/pages_controller.rb', line 36

def show

end

#updateObject



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

def update
  pages = Cartoset::Config['pages'] || []
  pages = pages.reject{|p| p['id'].eql?(params[:page][:id])}

  pages << params[:page]
  Cartoset::Config.update :pages => pages

  redirect_to admin_path
end