Comments (28)
This is not normal :)
I will investigate, and fix.
from parse-ruby-client.
I'm still a bit newby in Ruby, otherwise I would have fork it. I might try if you give me some hints haha :)
from parse-ruby-client.
Hints:
GeoPoint is defined in lib/parse/datatypes.rb and is tested in test/test_datatypes.rb.
Perhaps try improving the test function to show that it really should be failing, as it currently passes. Also, write an integrating test similar to the error you posted above. Right now, most tests are unit tests, and that really needs to change.
from parse-ruby-client.
I might be able to take a look at it tonight, but I think it would be wise if both of us take a look just in case haha :P
from parse-ruby-client.
Hi,
Just ran your code here and the object was saved correctly. What version of Ruby are you using?
from parse-ruby-client.
1.9.3
Sent from my iPhone
Envoyé de mon iPhone
On 2012-02-23, at 6:56 PM, "Leandro S."
[email protected]
wrote:
Hi,
Just ran your code here and the object was saved correctly. What version of Ruby are you using?
Reply to this email directly or view it on GitHub:
#2 (comment)
from parse-ruby-client.
And what version of parse-ruby-client? It should be 0.0.3.
On Thursday, February 23, 2012, Mathieu Allaire wrote:
1.9.3
Sent from my iPhone
Envoy de mon iPhoneOn 2012-02-23, at 6:56 PM, "Leandro S."
<[email protected] javascript:;>
wrote:Hi,
Just ran your code here and the object was saved correctly. What version
of Ruby are you using?
Reply to this email directly or view it on GitHub:
Reply to this email directly or view it on GitHub:
#2 (comment)
from parse-ruby-client.
The same I'm using. I tried with 1.9.2 and 1.8.7 and it worked too.
Here's the script I used:
require 'parse-ruby-client'
Parse.init :application_id => "<your_app_id>",
:api_key => "<your_api_key>"
parking_test = Parse::Object.new("ParkingTest")
data =
{
"longitude" => 40.0,
"latitude" => -30.0
}
point = Parse::GeoPoint.new(data)
parking_test["location"] = point
puts parking_test.to_json
parking_test.save
And the output:
{"location":{"__type":"GeoPoint","latitude":-30.0,"longitude":40.0}}
from parse-ruby-client.
Thats weird, Im using it in a rails project, but that's not a problem
I think... Weirdos, I'll try only in ruby with what you pasted
Sent from my iPhone
Envoyé de mon iPhone
On 2012-02-23, at 7:55 PM, "Leandro S."
[email protected]
wrote:
The same I'm using. I tried with 1.9.2 and 1.8.7 and it worked too.
Here's the script I used:
require 'parse-ruby-client' Parse.init :application_id => "<your_app_id>", :api_key => "<your_api_key>" parking_test = Parse::Object.new("ParkingTest") data = { "longitude" => 40.0, "latitude" => -30.0 } point = Parse::GeoPoint.new(data) parking_test["location"] = point puts parking_test.to_json parking_test.saveAnd the output:
{"location":{"__type":"GeoPoint","latitude":-30.0,"longitude":40.0}}
Reply to this email directly or view it on GitHub:
#2 (comment)
from parse-ruby-client.
Ok, it works #1 only in Ruby, but in my Rails project, I get the same error. I don't get it
def save
if (!valid?)
return false
else
parking = Parse::Object.new("Parking")
data =
{
"longitude" => 40.0,
"latitude" => -30.0
}
point = Parse::GeoPoint.new(data)
parking["location"] = point
parking.save
end
end
and here's a screenshot of the rails error : http://d.pr/h7YA
from parse-ruby-client.
I think I've found something, I did:
Parse.init :application_id => "app_id",
:api_key => "api_key"
parking_test = Parse::Object.new("Parking")
data =
{
"longitude" => 40.0,
"latitude" => -30.0
}
point = Parse::GeoPoint.new(data)
parking_test["location"] = point
logger.debug parking_test.to_json
#parking_test.save
and in the log, it returns:
{"location":{"longitude":40.0,"latitude":-30.0}}
Normally, it should also have the
"__type":"GeoPoint"
Correct?
from parse-ruby-client.
It seems to be a problem while converting the object to json. I can't see in your screenshot the correct representation for the parking object, there's nothing like "{"location":{"__type":"GeoPoint","latitude":-30.0,"longitude":40.0}}" in it.
Take a look at this SO question, it can help you: http://stackoverflow.com/questions/817287/ar-to-json-works-in-console-fails-in-browser
from parse-ruby-client.
I've tried the working code in ruby console in another controller, still failed. I also tried it in another rails project, didnt work. I don't see anything like the answer in the SO thread :(
I'm out of idea now :/
from parse-ruby-client.
Could you show me the gems you have installed? Do a "gem list"
I'm signing off now, but I'll try to reproduce the error using rails tomorrow :)
from parse-ruby-client.
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'pg'
gem 'parse-ruby-client'
gem 'bootstrap-sass', :git => 'git://github.com/thomas-mcdonald/bootstrap-sass.git'
group :production do
gem 'unicorn'
gem 'newrelic_rpm'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Thanks alot!
from parse-ruby-client.
I think it might be a as_json to_json issue, but not sure... See:
http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
http://stackoverflow.com/a/3630186
http://stackoverflow.com/questions/2556468/override-as-json-or-to-json-model-class-name
from parse-ruby-client.
Yes, you were right. Just added as_json method to all classes and the gem is working fine in a rails project.
from parse-ruby-client.
Is this a 'bug' ? Is it the responsibility of the gem to use as_json
or we should overwrite something in the project? Perhaps could you
share what you modified?
Thank you!
Sent from my iPhone
Envoyé de mon iPhone
On 2012-02-25, at 1:30 AM, "Leandro S."
[email protected]
wrote:
Yes, you were right. Just added as_json method to all classes and the gem is working fine in a rails project.
Reply to this email directly or view it on GitHub:
#2 (comment)
from parse-ruby-client.
Here's what I modified:
lsiqueira@bb4135f
from parse-ruby-client.
Awesome! Nice work @lsiqueira !
Would you mind explaining a bit more in details what was the problem in this particular situation?
Also, I see you changed the previous method to as_json but kept a to_json method, that's simply to not break previous compatibility? Or we have to use as_json with rails and to_json for everything else?
Thank you!
from parse-ruby-client.
@allaire, did this fix work for you?
In a perfect world, I'd like to have a test case that includes a Rails environment. However, if this did fix the issue, I'm inclined to just close it and not worry about it.
from parse-ruby-client.
When using the gem inside a Rails project the to_json method inside datatypes.rb was not being called, the as_json method was the one being used. I read this answer before realizing that: http://stackoverflow.com/a/6880638/106637
I don't know how to create a test case that includes a Rails environment, do you? If not, this is something we should add to the project's todo list :)
from parse-ruby-client.
Patch is fixing the issue, clever work @lsiqueira and thanks for the explanation!
from parse-ruby-client.
Also, may I ask what's the best way to test a patch like that? Is it by modyfing the gem directly (in my case on Mac in the .rvm folder) ?
from parse-ruby-client.
Nope, that would be a bad way to do it, imo.
Clone the repo somewhere. Run rake test
as needed. To use your local gem in another app, point to it in that app's Gemfile:
gem "restivus", :path => "../path/to/local/gem"
Then google around for GitHub's procedure on pull requests if you made something you think should be in the main repo.
from parse-ruby-client.
That make sense, thank you.
By the way, you can accept that pull request, it works flawlessly for my issue. So I'll close this, thank you.
from parse-ruby-client.
I did merge the request.
from parse-ruby-client.
Thank you guys!
from parse-ruby-client.
Related Issues (20)
- Why does this require bundler to run? HOT 2
- How to initialize Parse key HOT 3
- Parse Retirement HOT 10
- Can't use github master version HOT 5
- "both URI are relative" when configuring after self-hosted Parse server HOT 4
- unable to create client from console HOT 1
- Google OAuth Configuration
- client key shouldn't be required HOT 3
- Query can end up doing a POST! HOT 10
- Remove support for Ruby 1.9 and 2.0 HOT 4
- Running with local parse server HOT 2
- client.query - error client is undefined method in the contoller HOT 7
- back4app URL HOT 6
- Switch off parse.com HOT 3
- Switch tests to a hosted Parse server
- Multiple Coveralls comments
- Future of this project HOT 2
- Does Parse::Cloud::Function.new Still Work? HOT 2
- user = User.authenticate stopped working HOT 5
- NoMethodError occuered during retry request. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parse-ruby-client.