Reputation: 953
I have controller that is working with incoming GET requests.
GET request:
http://localhost:3000/sms/receive?sms-id=7bb28e244189f2cf36cbebb9d1d4d02001da53ab&operator-%20id=1&from=37126300682&to=371144&text=IL3+68975&charged=1
In both cases I need to respond GET request with 2 variables price and answer.
I have PHP example that works:
if (empty($login)){ // Ja abonents nav noradijis lietotajvardu (login), no vina netiek nonemta nauda un tiek nosutita kludas SMS
$price = 0.10;
$answer = "Atvainojiet, Jus neesat noradijusi lietotajvardu (login)SMS teksta. Uzmanigi parbaudiet nosutito tekstu!";
}else{ // Ja lietotajvards (login) noradits, abonents tiek tarificets
$price = 1.00;
$answer = "Paldies, ".$login."! Jusu SMS pienemta. Pakalpojuma cena ".$price.". Pakalpojums tiks piedavats pec apmaksas apstiprinajuma";
}
header("x-esteria-price: ".sprintf("%.2f", $price));
echo $answer;
exit();
But I can't understand how to do the same In Rails 4. I tried like this so far:
Controller:
if @billing.present? && @advertisement.present?
params[:answer] = "Paldies #{@advertisement.identifier} Jusu SMS pienemta. Pakalpojuma cena . Pakalpojums tiks piedavats pec apmaksas apstiprinajuma"
params[:price] = @billing.price
request.headers["x-esteria-price: 0.95"]
else
params[:answer] = "Atvainojiet, Jus neesat noradijusi lietotajvardu (login)SMS teksta. Uzmanigi parbaudiet nosutito tekstu!"
params[:price] = 0.10 #???
request.headers["x-esteria-price: 0.10"]
end
When I execute this code there is no error message shown.
Any tips ? Thanks in advance!
Upvotes: 0
Views: 139
Reputation: 4164
This line
request.headers["x-esteria-price: 0.10"]
is editing the header of the request not the response. Switch to request to response.
response.headers["x-esteria-price: 0.10"]
Upvotes: 1