Files
nairobi/app/controllers/admin/site_customization/images_controller.rb
Javi Martín 65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00

45 lines
1.2 KiB
Ruby

class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::BaseController
load_and_authorize_resource :image, class: "SiteCustomization::Image"
def index
@images = SiteCustomization::Image.all_images
end
def update
if params[:site_customization_image].nil?
redirect_to admin_site_customization_images_path
return
end
if @image.update(image_params)
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")
@images = SiteCustomization::Image.all_images
idx = @images.index { |e| e.name == @image.name }
@images[idx] = @image
render :index
end
end
def destroy
@image.image = nil
if @image.save
notice = t("admin.site_customization.images.destroy.notice")
else
notice = t("admin.site_customization.images.destroy.error")
end
redirect_to admin_site_customization_images_path, notice: notice
end
private
def image_params
params.require(:site_customization_image).permit(:image)
end
end