Class: Admin::PagesController
Instance Attribute Summary
#current_user
Instance Method Summary
collapse
#page_attachment_attributes, #page_content_attributes, #page_static_attributes
#redirect, underscore
#disable_static_cache!, #static_cached?
#policy, #verify_policy, #verify_policy_with_proc
inc_number_of_requests, original_title
#content_locale
#render_error
#authenticate!, #deauthenticate!, #logged_in?
Instance Method Details
#create ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/admin/pages_controller.rb', line 40
def create
@page = build_page(content_locale, page_params).tap(&:save)
respond_with_page(@page) do
if @page.valid?
redirect_to(edit_admin_page_url(content_locale, @page))
else
render action: :new
end
end
end
|
#deleted ⇒ Object
15
16
17
|
# File 'app/controllers/admin/pages_controller.rb', line 15
def deleted
@pages = Page.deleted.by_updated_at.in_locale(content_locale)
end
|
#destroy ⇒ Object
70
71
72
73
|
# File 'app/controllers/admin/pages_controller.rb', line 70
def destroy
Page.find(params[:id]).flag_as_deleted!
redirect_to admin_pages_url(content_locale)
end
|
#edit ⇒ Object
38
|
# File 'app/controllers/admin/pages_controller.rb', line 38
def edit; end
|
#index ⇒ Object
11
12
13
|
# File 'app/controllers/admin/pages_controller.rb', line 11
def index
@pages = Page.admin_list(content_locale)
end
|
#move ⇒ Object
64
65
66
67
68
|
# File 'app/controllers/admin/pages_controller.rb', line 64
def move
parent = params[:parent_id] ? Page.find(params[:parent_id]) : nil
@page.update(parent:, position: params[:position])
respond_with_page(@page) { redirect_to admin_pages_url(content_locale) }
end
|
#new ⇒ Object
32
33
34
35
36
|
# File 'app/controllers/admin/pages_controller.rb', line 32
def new
build_params = params[:page] ? page_params : nil
@page = build_page(content_locale, build_params)
@page.parent = Page.find_by(id: params[:parent])
end
|
#search ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/admin/pages_controller.rb', line 19
def search
return if search_query.blank?
@search_documents =
SearchDocument.where(searchable_type: "Page")
.search(search_query, locale: content_locale)
.paginate(per_page: 50, page: params[:page])
end
|
#show ⇒ Object
28
29
30
|
# File 'app/controllers/admin/pages_controller.rb', line 28
def show
redirect_to edit_admin_page_url(content_locale, @page)
end
|
#update ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/admin/pages_controller.rb', line 52
def update
@page.update(page_params)
respond_with_page(@page) do
if @page.valid?
flash[:notice] = t("pages_core.changes_saved")
redirect_to edit_admin_page_url(content_locale, @page)
else
render action: :edit
end
end
end
|