Class: Xing::Controllers::Base

Inherits:
ActionController::Base
  • Object
show all
Includes:
DeviseTokenAuth::Concerns::SetUserByToken
Defined in:
lib/xing/controllers/base.rb

Direct Known Subclasses

RootResourcesController

Instance Method Summary collapse

Instance Method Details

#check_formatObject



13
14
15
16
17
18
19
20
21
# File 'lib/xing/controllers/base.rb', line 13

def check_format
  if request.subdomains.include? Xing.backend_subdomain
    if request.headers["Accept"] =~ /json/
      params[:format] = :json
    else
      render :nothing => true, :status => 406
    end
  end
end

#failed_to_process(error_document) ⇒ Object



31
32
33
# File 'lib/xing/controllers/base.rb', line 31

def failed_to_process(error_document)
  render :status => 422, :json => error_document
end

#json_bodyObject



23
24
25
# File 'lib/xing/controllers/base.rb', line 23

def json_body
  @json_body ||= request.body.read
end

#parse_jsonObject



27
28
29
# File 'lib/xing/controllers/base.rb', line 27

def parse_json
  @parsed_json ||= JSON.parse(json_body)
end

#successful_create(new_resource_path) ⇒ Object



35
36
37
# File 'lib/xing/controllers/base.rb', line 35

def successful_create(new_resource_path)
  render :status => 201, :json => {}, :location => new_resource_path
end