i am trying to update a Users information for ex. Phone, email etc.
i looked at this: https://parse.com/docs/rest/guide#users-updating-users
so i wrote this in my controller:
@response = HTTParty.put('https://api.parse.com/1/users/',
:headers => {"X-Parse-Application-Id" => "APIKEY",
"X-Parse-REST-API-Key" => "APIKEY",
"X-Parse-Session-Token" => session[:session_token],
"Content-Type" => "application/json"},
:data => {"phoneNumber" => "9994432"})
I return @response
in a view and get back this:
{"error"=>"requested resource was not found"}
I was thinking maybe its because im not passing the user's objectid in the url?
Well, now that you have played with creating HTTP requests to API manually, it's time to switch to some library/gem for interactions with Parse. Hopefully, people who built the library that you will find, already have dealt with many routine tasks (like formatting your JSON properly – the error you are investigating right now), and have good documentation for many cases.
I suggest parse-ruby-client.
Add
gem 'parse-ruby-client', github: 'adelevie/parse-ruby-client'
to Gemfile (it's better to usemaster
version, not the current Rubygems version, because they are saying that there are some useful changes which are not yet pushed to Rubygems), then runbundle install
as usual, and you are good to go.Object saving is as easy as
according to their documentation.
UPD. Answering original question. You can use a function to provide object id dynamically:
My solution is force the variables to int and string