Files
openfoodnetwork/app/controllers/admin/contents_controller.rb
Pau Pérez Fabregat 20077c99b5 Merge pull request #2618 from coopdevs/enable-style-send-cop
Favor #public_send over #send using Rubocop's cop
2018-09-20 19:03:40 +02:00

40 lines
1.2 KiB
Ruby

module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@preference_sections = preference_sections.map do |preference_section|
{ name: preference_section.name, preferences: preference_section.preferences }
end
end
def update
params.each do |name, value|
if ContentConfig.has_preference?(name) || ContentConfig.has_attachment?(name)
ContentConfig.public_send("#{name}=", value)
end
end
# Save any uploaded images
ContentConfig.save
flash[:success] = t(:successfully_updated, :resource => I18n.t('admin.contents.edit.your_content'))
redirect_to main_app.edit_admin_content_path
end
private
def preference_sections
[
PreferenceSections::HeaderSection.new,
PreferenceSections::HomePageSection.new,
PreferenceSections::ProducerSignupPageSection.new,
PreferenceSections::HubSignupPageSection.new,
PreferenceSections::GroupSignupPageSection.new,
PreferenceSections::MainLinksSection.new,
PreferenceSections::FooterAndExternalLinksSection.new,
PreferenceSections::UserGuideSection.new
]
end
end
end