Sha256: 17278d5393dbf92534374aab29f2190fd0724ca73c1af9ba4647bfe78d4e32e9
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
module Dorsale module Alexandrie class AttachmentsController < ::Dorsale::ApplicationController def create @attachment = ::Dorsale::Alexandrie::Attachment.new(attachment_params) authorize! :create, @attachment if @attachment.save flash[:notice] = t("messages.attachments.create_ok") else ap @attachment.errors flash[:alert] = t("messages.attachments.create_error") end redirect_to_back_url end def destroy @attachment = ::Dorsale::Alexandrie::Attachment.find params[:id] authorize! :delete, @attachment if @attachment.destroy flash[:notice] = t("messages.attachments.delete_ok") else flash[:alert] = t("messages.attachments.delete_error") end redirect_to_back_url end private def permitted_params_for_attachment [ :attachable_id, :attachable_type, :file, ] end def attachment_params params .require(:attachment) .permit(permitted_params_for_attachment) .merge(sender: current_user) end def redirect_to_back_url redirect_to params[:back_url] || request.referer end end end end
Version data entries
5 entries across 5 versions & 1 rubygems