Class: Admin::PagesController
Instance Method Summary
collapse
Methods included from BlogHelper
#blog_base_url, #this_blog
Instance Method Details
#create ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/admin/pages_controller.rb', line 28
def create
@page = Page.new(page_params)
@page.published_at = Time.zone.now
@page.blog = this_blog
@page.user_id = current_user.id
if @page.save
redirect_to admin_pages_url, notice: I18n.t("admin.pages.new.success")
else
render :new, layout: "editor"
end
end
|
#destroy ⇒ Object
50
51
52
|
# File 'app/controllers/admin/pages_controller.rb', line 50
def destroy
destroy_a(Page)
end
|
#edit ⇒ Object
23
24
25
26
|
# File 'app/controllers/admin/pages_controller.rb', line 23
def edit
@page.text_filter_name ||= default_text_filter
render layout: "editor"
end
|
#index ⇒ Object
9
10
11
12
13
|
# File 'app/controllers/admin/pages_controller.rb', line 9
def index
@search = params[:search] || {}
@pages = Page.search_with(@search).page(params[:page])
.per(this_blog.admin_display_elements)
end
|
#new ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/controllers/admin/pages_controller.rb', line 15
def new
@page = Page.new
@page.text_filter_name ||= default_text_filter
@page.user_id = current_user.id
@page.state = "published"
render layout: "editor"
end
|
#update ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'app/controllers/admin/pages_controller.rb', line 41
def update
@page.text_filter_name ||= default_text_filter
if @page.update(page_params)
redirect_to admin_pages_url, notice: I18n.t("admin.pages.edit.success")
else
render :edit
end
end
|