Class: Symphonia::AttachmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/symphonia/attachments_controller.rb

Instance Method Summary collapse

Methods included from ControllerExtensions

#admin_require, #authorize, #back_url, #current_user, #current_user_session, #handle_unverified_request, #login_require, #menu_item, #redirect_back_or_default, #redirect_to_referer_or, #render_403, #render_404, #render_api_head, #render_api_ok, #set_default_locale, #set_locale, #store_location

Instance Method Details

#destroyObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/symphonia/attachments_controller.rb', line 11

def destroy
  # find_attachment
  @attachment.destroy
  respond_to do |format|
    format.html do
      flash[:notice] = t(:"text_#{@attachment.type.underscore}_successfully_destroy")
      redirect_back_or_default(polymorphic_path(@attachment.attachable))
    end
    format.js
  end
end

#reorderObject



23
24
25
26
27
28
# File 'app/controllers/symphonia/attachments_controller.rb', line 23

def reorder
  # find_attachment
  new_position = params.require(:position).to_i
  @attachment.insert_at(new_position)
  head :ok
end

#showObject



6
7
8
9
# File 'app/controllers/symphonia/attachments_controller.rb', line 6

def show
  # find_attachment
  render(plain: @attachment.attachment.url(:original), layout: false)
end