diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 32e38eb84..7ed555275 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -59,10 +59,11 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController end def poll_params - params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, - :summary, :description, :results_enabled, :stats_enabled, - geozone_ids: [], - image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) + image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] + attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description, + :results_enabled, :stats_enabled, geozone_ids: [], + image_attributes: image_attributes] + params.require(:poll).permit(*attributes) end def search_params diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb index bef176a22..3833111b9 100644 --- a/app/controllers/admin/poll/questions/answers_controller.rb +++ b/app/controllers/admin/poll/questions/answers_controller.rb @@ -47,7 +47,9 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController private def answer_params - params.require(:poll_question_answer).permit(:title, :description, :question_id, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) + documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] + attributes = [:title, :description, :question_id, documents_attributes: documents_attributes] + params.require(:poll_question_answer).permit(*attributes) end def load_answer diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb index 1261f2951..d2ef8e74e 100644 --- a/app/controllers/admin/poll/shifts_controller.rb +++ b/app/controllers/admin/poll/shifts_controller.rb @@ -15,7 +15,8 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController @officer = @shift.officer if @shift.save - redirect_to new_admin_booth_shift_path(@shift.booth), notice: t("admin.poll_shifts.flash.create") + notice = t("admin.poll_shifts.flash.create") + redirect_to new_admin_booth_shift_path(@shift.booth), notice: notice else load_shifts flash[:error] = t("admin.poll_shifts.flash.date_missing") @@ -31,7 +32,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController end def search_officers - @officers = User.search(params[:search]).order(username: :asc).select { |o| o.poll_officer? == true } + @officers = User.search(params[:search]).order(username: :asc).select { |o| o.poll_officer? } end private @@ -51,7 +52,9 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController end def shift_params - shift_params = params.require(:shift).permit(:booth_id, :officer_id, :task, date: [:vote_collection_date, :recount_scrutiny_date]) + date_attributes = [:vote_collection_date, :recount_scrutiny_date] + attributes = [:booth_id, :officer_id, :task, date: date_attributes] + shift_params = params.require(:shift).permit(*attributes) shift_params.merge(date: shift_params[:date]["#{shift_params[:task]}_date".to_sym]) end end diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index 02cf44aaf..dbc09b3da 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -8,7 +8,8 @@ class Admin::ProposalsController < Admin::BaseController before_action :load_proposal, only: [:confirm_hide, :restore] def index - @proposals = Proposal.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page]) + @proposals = Proposal.only_hidden.send(@current_filter).order(hidden_at: :desc) + .page(params[:page]) end def confirm_hide diff --git a/app/controllers/admin/site_customization/content_blocks_controller.rb b/app/controllers/admin/site_customization/content_blocks_controller.rb index 2f0843ccc..1697cb76f 100644 --- a/app/controllers/admin/site_customization/content_blocks_controller.rb +++ b/app/controllers/admin/site_customization/content_blocks_controller.rb @@ -7,7 +7,8 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati def create if @content_block.save - redirect_to admin_site_customization_content_blocks_path, notice: t('admin.site_customization.content_blocks.create.notice') + notice = t('admin.site_customization.content_blocks.create.notice') + redirect_to admin_site_customization_content_blocks_path, notice: notice else flash.now[:error] = t('admin.site_customization.content_blocks.create.error') render :new @@ -16,7 +17,8 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati def update if @content_block.update(content_block_params) - redirect_to admin_site_customization_content_blocks_path, notice: t('admin.site_customization.content_blocks.update.notice') + notice = t('admin.site_customization.content_blocks.update.notice') + redirect_to admin_site_customization_content_blocks_path, notice: notice else flash.now[:error] = t('admin.site_customization.content_blocks.update.error') render :edit @@ -25,7 +27,8 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati def destroy @content_block.destroy - redirect_to admin_site_customization_content_blocks_path, notice: t('admin.site_customization.content_blocks.destroy.notice') + notice = t('admin.site_customization.content_blocks.destroy.notice') + redirect_to admin_site_customization_content_blocks_path, notice: notice end private diff --git a/app/controllers/admin/site_customization/images_controller.rb b/app/controllers/admin/site_customization/images_controller.rb index c9f318f41..21951f527 100644 --- a/app/controllers/admin/site_customization/images_controller.rb +++ b/app/controllers/admin/site_customization/images_controller.rb @@ -12,7 +12,8 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas end if @image.update(image_params) - redirect_to admin_site_customization_images_path, notice: t('admin.site_customization.images.update.notice') + notice = t('admin.site_customization.images.update.notice') + redirect_to admin_site_customization_images_path, notice: notice else flash.now[:error] = t('admin.site_customization.images.update.error') @@ -27,9 +28,11 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas def destroy @image.image = nil if @image.save - redirect_to admin_site_customization_images_path, notice: t('admin.site_customization.images.destroy.notice') + notice = t('admin.site_customization.images.destroy.notice') + redirect_to admin_site_customization_images_path, notice: notice else - redirect_to admin_site_customization_images_path, notice: t('admin.site_customization.images.destroy.error') + notice = t('admin.site_customization.images.destroy.error') + redirect_to admin_site_customization_images_path, notice: notice end end diff --git a/app/controllers/admin/site_customization/pages_controller.rb b/app/controllers/admin/site_customization/pages_controller.rb index dd65fb52e..68ede1da2 100644 --- a/app/controllers/admin/site_customization/pages_controller.rb +++ b/app/controllers/admin/site_customization/pages_controller.rb @@ -7,7 +7,8 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base def create if @page.save - redirect_to admin_site_customization_pages_path, notice: t('admin.site_customization.pages.create.notice') + notice = t('admin.site_customization.pages.create.notice') + redirect_to admin_site_customization_pages_path, notice: notice else flash.now[:error] = t('admin.site_customization.pages.create.error') render :new @@ -16,7 +17,8 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base def update if @page.update(page_params) - redirect_to admin_site_customization_pages_path, notice: t('admin.site_customization.pages.update.notice') + notice = t('admin.site_customization.pages.update.notice') + redirect_to admin_site_customization_pages_path, notice: notice else flash.now[:error] = t('admin.site_customization.pages.update.error') render :edit @@ -25,7 +27,8 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base def destroy @page.destroy - redirect_to admin_site_customization_pages_path, notice: t('admin.site_customization.pages.destroy.notice') + notice = t('admin.site_customization.pages.destroy.notice') + redirect_to admin_site_customization_pages_path, notice: notice end private