Class: Xing::Controllers::Base
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Xing::Controllers::Base
- Includes:
- DeviseTokenAuth::Concerns::SetUserByToken
- Defined in:
- lib/xing/controllers/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #check_format ⇒ Object
- #failed_to_process(error_document) ⇒ Object
- #json_body ⇒ Object
- #parse_json ⇒ Object
- #successful_create(new_resource_path) ⇒ Object
Instance Method Details
#check_format ⇒ Object
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_body ⇒ Object
23 24 25 |
# File 'lib/xing/controllers/base.rb', line 23 def json_body @json_body ||= request.body.read end |
#parse_json ⇒ Object
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 |