Class: Satis::AttachmentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Satis::AttachmentsController
- Defined in:
- app/controllers/satis/attachments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/controllers/satis/attachments_controller.rb', line 13 def create params[:attachments].each do |file| @model.public_send(@attachment_type).attach(file) end redirect_to request.referer || root_path, notice: "Attachment created successfully." end |
#destroy ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/satis/attachments_controller.rb', line 21 def destroy = @model.public_send(@attachment_type).find_by(id: params[:id]) &.purge redirect_to request.referer || root_path, notice: "Attachment deleted successfully." end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/satis/attachments_controller.rb', line 8 def index @attachments = @model.public_send(@attachment_type) render json: @attachments end |