Difference between revisions of "Ruby Bindings for E-Commerce Tutorial"
(→Creating the testing database) |
|||
Line 38: | Line 38: | ||
</table> | </table> | ||
− | It really can't get much simpler than that. You can get a dump of the database [[Media:examplestore.mysql|here]]. If you have a local MySQL running, you can create and import the database with these commands: | + | It really can't get much simpler than that. '''You can get a dump of the database [[Media:examplestore.mysql|here]].''' If you have a local MySQL running, you can create and import the database with these commands: |
<pre> | <pre> | ||
Line 59: | Line 59: | ||
Unless you changed the password above, the password is just ''password''. You've now got the same data that the examples use imported to a database called ''examplestore''. | Unless you changed the password above, the password is just ''password''. You've now got the same data that the examples use imported to a database called ''examplestore''. | ||
+ | |||
+ | == Setting up the Ruby plumbing == |
Revision as of 14:37, 25 May 2009
One of the main things that people often want to do is to integrate Directed Edge's recommendation engine into their online store. Many of those stores are using Ruby already, so we decided to give a very concrete walk-through of doing recommendations based on previous customer purchases starting from exporting data all the way to keeping it in sync.
If you want to see all of the code in one go, you can get it in full syntax-highlighted glory here: ExampleStore Class, or download it here. You'll also want our Ruby bindings, which you can get from GitHub here (download).
Creating the testing database
You've probably got your own site's database that you're more interested in, but if you want to follow along in the code, you can use the store data that we randomly generated. We created 2000 users with 500 products and had each of those users "buy" between 0 and 30 products.
For that we created three very simple tables. Since we don't care about the other properties of the customers or products, all that those tables contain is an ID. The purchase table just contains customer and product columns.
customers table:
|
products table:
|
purchases table:
|
It really can't get much simpler than that. You can get a dump of the database here. If you have a local MySQL running, you can create and import the database with these commands:
$ mysql --user=root
You should now be at the MySQL prompt:
mysql> create database examplestore; mysql> create user 'examplestore'@'localhost' identified by 'password'; mysql> grant all on examplestore.* to 'examplestore'@'localhost';
Now back at the command line do:
$ mysql --user=examplestore -p examplestore < examplestore.mysql
Unless you changed the password above, the password is just password. You've now got the same data that the examples use imported to a database called examplestore.