Reputation: 1021
I am trying to implement Watson callback function in Ruby on Rails and they say I should omit the quote in the return.
I created get method to return what was received. The url is "http://someurl/api/v1/resoucename/results?somevalue=123123", I return 123123 as "123123"
resource :resoucename do
get :results do
return params[:somevalue]
end
end
How can I return a unquoted value?
Watson says: The request includes an Accept header that specifies text/plain as the required response type.
If anyone has an idea how to return as it is, please share with me! Best
Upvotes: 0
Views: 54
Reputation: 33470
If you have "123123"
then you have an string, an integer would be unquoted, like:
p "123123"
# => "123123"
p "123123".to_i
# => 123123
So most probably you could "tweak" your method to:
resource :resoucename do
get :results do
params[:somevalue].to_i
end
end
Upvotes: 1