Class: Assetable::ExternalServicesController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/assetable/external_services_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Create a new external service asset



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/assetable/external_services_controller.rb', line 16

def create
  @external_service = ExternalService.new(permitted_params)

  if @external_service.errors.empty? and @external_service.save
    render json: { success: true, html: render_to_string(partial: "assetable/assets/asset", locals: { asset: @external_service, fieldname: params[:fieldname]})}
  else
    puts "errors:: #{@external_service.errors.full_messages}"
    render json: { status: "error", errors: @external_service.errors.full_messages, html: render_to_string(:new) }
  end
end

#newObject

New template



11
12
13
# File 'app/controllers/assetable/external_services_controller.rb', line 11

def new
  @external_service = ExternalService.new
end

#permitted_paramsObject

Permitted params for the model



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/assetable/external_services_controller.rb', line 28

def permitted_params
  params.require(:external_service).permit(
    :name,
    :filename,
    :body,
    :content_type,
    :width,
    :height
  )
end