Class: Virgo::Admin::PageModulesController
Instance Method Summary
collapse
#authorize_admin_user, #search, #set_is_admin_view
#render_content, #with_format
#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count
Instance Method Details
#edit ⇒ Object
8
9
10
11
12
|
# File 'app/controllers/virgo/admin/page_modules_controller.rb', line 8
def edit
authorize! :manage, PageModule
@page_modules = PageModule.visible_to_admins.order(weight: :asc)
end
|
#edit_subject ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/virgo/admin/page_modules_controller.rb', line 14
def edit_subject
if request.patch?
if page_module_params.nil? || @page_module.update(page_module_params)
@page_module.page_module_posts.map &:destroy
if params[:post_ids].present?
params[:post_ids].each_with_index do |post_id, index|
@page_module.page_module_posts.create!(post_id: post_id, position: index)
end
end
flash[:notice] = "Settings updated successfully"
redirect_to admin_edit_page_module_subject_path(@page_module) and return
end
end
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/virgo/admin/page_modules_controller.rb', line 29
def update
authorize! :manage, PageModule
params[:page_modules].each_pair do |id, enabled_val|
page_module = PageModule.find(id)
page_module.update!(enabled: enabled_val)
end
flash[:notice] = "Page module settings updated"
redirect_to admin_page_modules_edit_path
end
|