Class: FrontEndBuilds::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/front_end_builds/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#error!(errors, status = :unprocessable_entity) ⇒ Object



15
16
17
# File 'app/controllers/front_end_builds/application_controller.rb', line 15

def error!(errors, status = :unprocessable_entity)
  respond_with_json({ errors: errors }, status: status)
end

#respond_with_json(object, options = {}) ⇒ Object

Public: A quick helper to create a respond_to block for returning json to the client. Used because ‘respond_with` is no longer included in Rails.



7
8
9
10
11
12
13
# File 'app/controllers/front_end_builds/application_controller.rb', line 7

def respond_with_json(object, options = {})
  respond_to do |format|
    format.json do
      render options.merge(json: object)
    end
  end
end