class MaintenanceEntryImagesController < ApplicationController def destroy attachment = maintenance_entry.images.attachments.find(params[:attachment_id]) attachment.purge redirect_to images_vehicle_maintenance_entry_path(vehicle, maintenance_entry), status: :see_other, notice: "Maintenance image deleted." end private def vehicle @vehicle ||= Vehicle.find(params[:vehicle_id]) end def maintenance_entry @maintenance_entry ||= vehicle.maintenance_entries.find(params[:maintenance_entry_id]) end end