Neo4j with Ruby On Rails - ruby-on-rails

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.

Related

How to connect Rails app to a website's API?

I know I'm going to get downvotes for even asking but I honestly have no clue how to do this and any assistance would be appreciated as I have never done this.
I have a client that migrated their blog to HubSpot and would like to have their blog posts displayed on their website. So how do I connect to HubSpot's API to display the blog in their website that I have in a Rails app?
Do I create MVC just for Blog API? Where do I put the URL to connect to?
If you want to connect to an other API the best way to do this is to create service objects. These are plain old Ruby objects (aka PORO) that represent the API as a Ruby object. You are free to use any location you want, but I would stick them in lib/services or app/services. If the provided API uses the Rails (REST) standards than you might be able to use ActiveResource.
You could also look for gems that provide these service objects. A quick RubyGem search finds multiple (unofficial) gems. From witch hubspot-ruby seems the most used and active.
If the gems don't do what you want you could look through the code to find some inspiration and create you own objects. Another option is to fork a project and add the functionality you want.
Here is a link to answer the broader question you're asking: What is the proper "Rails Way" to consume a RESTful web service on another domain?

Is there Getting Started RAILS documentation for someone only interested in developing REST APIs?

Our team will be using Rails for the development of RESTful APIs only. We will use Ember or Angular for our GUI layer and will sometimes just publish our APIs for external consumption. For someone such as myself who doesn't know Rails at all yet, and doesn't really want to learn the View part, finding good "getting started" documentation hasn't been very successful. I've found a few articles on how to build REST APIs, but even these articles seems to assume prior Rails knowledge. Can anyone point me to docs for a Rails newcomer who only wants to build REST APIs? Thanks!
Check out: https://github.com/rails-api/rails-api
This is a starting point for a version of Rails better suited for JS-heavy apps.
Rails API provides: trimmed down controllers and set of generators, specifically built for API type applications.

Simplest way for understanding MongoDB iphone

What is the simplest way of understanding about mongoDB? i know there's something called as NuMongo wrapper to to interact with mongoDB, but yet its not yet clear in my head. Can some please share the knowledge ?
Thanks
Directly accessing a MongoDB database from a mobile device is probably not a good idea. The main limitation is that the Mongo wire protocol has no encryption.
You can build an application server as middleware, in almost any language you like.
That said, ObjCMongoDB (of which I'm author) has support for iOS, so if you decide you want to give it a go anyway, you can.
If you want to write an application server on Mac OS using Objective-C, you can also use ObjCMongoDB for that, along with something like CocoaHTTPServer.
An very simple way is to set up a Rails Application with some mongoDB PlugIn, e.g. mongomapper and in Rails you can define the web service to communicate with the iPhone.
These links are very good to understand Rails and mongomapper:
Rails Guides
MongoMapper Documentation

Neo4j spatial in ruby

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.

Start using Ruby on Rails, Web Services and OAuth

I am running Ruby on Rails 3 and I would like to create an application APP1 that acts as a Web Service. Then create another RoR application APP2 that can communicate (send/get information) with APP1 using the OAuth protocol.
What I have to do to start (I am not expert about programming in those topics but I read a lot and I know how they conceptually\theoretically works)? Is it good to think to implement my custom code or maybe it is better to use plugin or gem? Why?
If it is possible, can you write a TODO list and steps to accomplish what I aim?
And, more important, can you suggest me some useful (awesome) resources (like books, blog posts, ...) about creating RoR Web Services?
Assuming you get to decide what kind of Web Service you want, and a RESTful XML Web Service is an acceptable choice, then Rails applications practically do this by default. When you generate scaffolding code, your controller will actually be ready to interface with as a RESTful Web Service.
Of course, that's not everything you need to know and do, but the subject seems to be covered very well by the following series of articles...
http://css.dzone.com/news/rest-with-rails-part-1
http://css.dzone.com/news/rest-with-rails-part-2-serving
http://css.dzone.com/news/rest-with-rails-part-iii-using
Unfortunately, there seem to be some JavaScript errors on those pages, but they're still usable.
I know this doesn't answer the OAuth part of your question, but this article ( http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails ) apears to have some useful information on that subject. Note that the info here is slightly out of date if you'll be using Rails 3 because you'll want to list the gems in your Gemfile and run bundle install rather than adding config.gem ... lines to your environment.rb file.

Resources