Module: Voltron::Upload

Defined in:
lib/voltron/upload.rb,
lib/voltron/upload/error.rb,
lib/voltron/upload/engine.rb,
lib/voltron/upload/version.rb,
lib/voltron/upload/action_view/field.rb,
lib/voltron/upload/active_record/base.rb,
lib/voltron/upload/action_dispatch/routes.rb,
lib/voltron/upload/carrierwave/uploader/base.rb,
lib/generators/voltron/upload/install_generator.rb,
lib/generators/voltron/upload/install/views_generator.rb,
lib/generators/voltron/upload/install/assets_generator.rb

Defined Under Namespace

Modules: Base, CarrierWave, ControllerMethods, Field, Generators, Routes Classes: Engine, Error

Constant Summary collapse

LOG_COLOR =
:light_cyan
VERSION =
'0.2.5'.freeze

Instance Method Summary collapse

Instance Method Details

#uploadable(resource = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/voltron/upload.rb', line 16

def uploadable(resource = nil)
  include ControllerMethods

  resource ||= controller_name
  @uploader ||= Voltron::Uploader.new(resource)

  rescue_from ActionController::InvalidAuthenticityToken do |e|
    raise unless action_name == 'upload'
    render json: { success: false, error: 'Invalid authenticity token provided' }, status: :unauthorized
  end
end