Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Last active August 29, 2015 14:02
Show Gist options
  • Save luckyruby/037f1a8180a3e3e5e70d to your computer and use it in GitHub Desktop.
Save luckyruby/037f1a8180a3e3e5e70d to your computer and use it in GitHub Desktop.
class RequestsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :parse_xml
def ping
@response_tag = "OTA_PingRS"
rescue => e
log_error(e)
@error = e
render template: 'requests/error'
end
private
def log_error(e)
Rails.logger.error e.message
Rails.logger.error e.backtrace.join("\n")
end
def parse_xml
@msg = Nori.new.parse(request.body.read)
end
end
Rails.application.routes.draw do
post 'ping' => 'requests#ping'
end
xml.instruct!
xml.tag!(@response_tag) {
xml.Success
xml.EchoData @msg["OTA_PingRQ"]["EchoData"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment