JayData.org

Using JayData with Ruby on Rails and YQL

Author: Janos Roden June 21st, 2012

, ,


In this example you can learn how to use a custom Ruby on Rails data source with JayData, without the need to write an own provider. You can download this Rails and JayData projects and setup your local development environment.

Ruby on Rails

We will create the server-side Ruby on Rails application and generate the following basic files:

Create and seed the database. In the nw.sql you can find the Categories and Products table of the Northwind database (the DB creation script can be found in the rails_demo/public folder inside YQLWithRails.zip, so save the nw.sql to the parent directory).

Modify the app/controllers/categories_controller.rb file by adding XML response:

Do the same in the app/controllers/products_controller.rb file:

In the config/routes.rb replace the generated rules:

Now you can try out what we have so far. Start the development webserver:

In a different console, watch the results:

YQL

Publish your application to a public location where Yahoo can access it. The following two files define the Categories and Products tables. (See Open Data Tables Reference):

public/products.xml

public/categories.xml

Another environment file (public/tables.env):

Now you can try it in the developer console: http://developer.yahoo.com/yql/console/?env=http://jaydata.org/examples/rails/tables.env

JayData

Everything is ready to use JayData to access our tables from JavaScript. Define the entities and context:

Select cheap products:

Console:


, ,