I recently started playing with neo4j graph database in a Rails application and loved how rich the neo4j is. Although I saw that there is spatial support for neo4j via neo4j-spatial I haven't seen an example in a ruby application to get me started (using the ruby port of neo4j-spatial).
What I want to accomplish at first is to have a User model and a Poi model both having lat, lng attributes and make a query: Show me the Poi's that are at most 10km away from me
but I have no idea how I have to go about using the ruby gem. All I have found on the subject is this blog spot.
Does anyone know how am I supposed to do this in ruby? Thanks!
I think the ruby gem is a bit out of date. I suggest either forking and updating it, or use straight Java APIs for that, see the original java methods that the Spatial ruby just wraps.
Lemme know if you want to contribute and update, would be great!
I wrote the gem as a simple wrapper. It depends on neo4j.rb so you get all the necessary ruby on rails capabilities from that. Then it includes the spatial dependencies also. In addition it provides utilities for wrapping OSM import and export and dynamic layer support. It does not provide utilities to wrap the simple point layer which you seem to want. However you kind of get that for free anyway with jruby directly wrapping all of the java API for you.
My recommendation would be to use neo4j-spatial.rb and then use the neo4j.rb capabilities to build your model. Access the simple point layer directly from jruby and just add your new nodes to that. Then you can call the distance search function, also from jruby.
Related
I'm quite novice to neo4j. I would like to find out if I can query a neo4j database from a ruby on rails application and use the result to make a graph visualization in my application. I have looked at d3.js, that problably can do it. I would just like to know if it possible to use GraphGist in a ruby on rails application and make a graph visualization as can be seen here. If I can use GraphGist where can I find more information how to use in a ruby on rails project? If I cannot use GraphGist would d3.js be a good choice of vizualizing neo4j graphs in a Ruby on Rails project?
I wrote a simple single html page Neo4j console that you can use to learn how do to it.
The master branch uses the alchemy.js library http://jexp.github.io/cy2neo
And the neod3 branch uses the visualization from the graphgist project.
If you clone it locally and check out that branch and run the file in a browser you should be able to see the visualization.
I created a ruby on rails web app which I deployed on heroku, by following this guide
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
The app is very similar to this tutorial in that a user can create an account, log in, create an object with some information which is belongs to that user. These objects I created are meant to represent nodes which I would like to be able to create relationships between.
I have been reading up on Neo4j and it seems like the best fit for ruby but then I read that it only really works with JRuby. Could anyone tell me would it work with my implementation and if so , how? or if it dosent, what should I use instead?
JRuby allows Ruby to access Neo4j directly through the Java API. It is the fastest implementation possible. However, Neo4j also provides a REST API that allows any language to access it over HTTP.
I seems like your answer may be here: Which Ruby REST API client for neo4j?
This is again using the Neography gem, but this blog maxdemarzi has got some really nice posts on integrating ruby with neo4j.
Here's a link: http://maxdemarzi.com/2012/01/04/getting-started-with-ruby-and-neo4j/
But as mentioned by others, I don't think you'd get anything that can talk directly to the Java API other than JRuby.
I will be implementing a search feature on a project to allow a user to find the nearest store based on driving time given a input physical address. I would prefer showing a Google maps of the closest dealers. I am using PostgreSQL 8.4.x with Rails 2.1. Can anyone recommend a good solution (Ruby gem, Maps API such Google, PostGIS database, etc)? Thanks, Chirag
I generally use Geokit:
https://github.com/andre/geokit-gem
Or Geokit Rails 3:
https://github.com/jlecour/geokit-rails3
Then of course, I use my gem gmaps4rails
Haven't really done anything like that before, but these resources should be quite useful :
http://ym4r.rubyforge.org/tutorial_ym4r_georuby.html
https://github.com/apneadiving/Google-Maps-for-Rails
I would like to do a very simple task: add some markers in a Google Map using a list of addresses from an array.
I have been thinking about generating the Google Maps JavaScript API code using ruby (printf) but this does not seem like a very clean and beautiful solution...
I have read about YM4R for Ruby on Rails... my project is pretty simple and I have never worked with Ruby on Rails... I have also never used JQuery... but I am very willing to learn to use this tools :)
What do you think will be the best approach to generating the markers?
Fyi, I've just released a new version of gmaps4rails.
It's based on Rails 3 and uses Google maps API V3:
https://github.com/apneadiving/Google-Maps-for-Rails
YM4R is a good choice. In the end you'll just need a few lines of code to get this done, as outlined in the tutorial. Even given your background, you should be able to follow the examples and get things working.
We also use the Geokit plugin, which is a little more complicated because of the set-up. But if you already have the lat/lon, you're good.
Is there a pattern or a gem (Ruby on rails) for modeling the wiki-like behaviour of a StackOverflow like web site?
I'm working on Ruby-on-Rails project so a gem or something in RoR would be appreciated but a well defined pattern is just as good.
Thanks
Did you try act_as_versioned? It is available as a gem, and adds simple versioning to any ActiveRecord model.
If you need more features, act_as_revisable might be interesting. According to the link, it adds the following features on top of act_as_versioned:
Pervasive Callbacks
Branching and Changesets
Deletes can be stored as a revision
Explicit is better than implicit
All data for a model is stored in one table
Wrapping up, requirements and installing