Class: Admin::PagesController
Instance Attribute Summary
#current_user
Instance Method Summary
collapse
#page_json, #page_permissions
#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
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/admin/pages_controller.rb', line 41
def create
@page = build_page(content_locale, page_params,
param_categories).tap(&:save)
if @page.valid?
respond_with_page(@page) do
redirect_to(edit_admin_page_url(content_locale, @page))
end
else
render action: :new
end
end
|
#deleted ⇒ Object
16
17
18
|
# File 'app/controllers/admin/pages_controller.rb', line 16
def deleted
@pages = Page.deleted.by_updated_at.in_locale(content_locale)
end
|
#destroy ⇒ Object
71
72
73
74
|
# File 'app/controllers/admin/pages_controller.rb', line 71
def destroy
Page.find(params[:id]).flag_as_deleted!
redirect_to admin_pages_url(content_locale)
end
|
#edit ⇒ Object
39
|
# File 'app/controllers/admin/pages_controller.rb', line 39
def edit; end
|
#index ⇒ Object
12
13
14
|
# File 'app/controllers/admin/pages_controller.rb', line 12
def index
@pages = Page.admin_list(content_locale)
end
|
#move ⇒ Object
65
66
67
68
69
|
# File 'app/controllers/admin/pages_controller.rb', line 65
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
33
34
35
36
37
|
# File 'app/controllers/admin/pages_controller.rb', line 33
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
20
21
22
23
24
25
26
27
|
# File 'app/controllers/admin/pages_controller.rb', line 20
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
29
30
31
|
# File 'app/controllers/admin/pages_controller.rb', line 29
def show
redirect_to edit_admin_page_url(content_locale, @page)
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/admin/pages_controller.rb', line 53
def update
if @page.update(page_params)
@page.categories = param_categories
respond_with_page(@page) do
flash[:notice] = t("pages_core.changes_saved")
redirect_to edit_admin_page_url(content_locale, @page)
end
else
render action: :edit
end
end
|