xml - Way to return True/False with rails api? -
i need create method, gets called local application 2 parameters. how can return true or false then? xml? method looks this:
def check_license app_id = params[:id] app_sn = params[:sn] @license = license.find_by_id(app_id) respond_to |format| if @license.app_serial == app_sn # should return true here else # should return false here end end end
thanks in advance!
you first need decide format other internal application call application. popular (and sane) formats xml or json.
then, in controller, need render response in each of formats:
resp = @license.app_serial == app_sn respond_to |format| format.json { render :json => resp } format.xml if resp head :ok else render :xml => resp, :status => 403 # that's failed authentication response end end end
Comments
Post a Comment