We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpProcessing Implementations › ruby-processing & active record
Page Index Toggle Pages: 1
ruby-processing & active record (Read 3260 times)
ruby-processing & active record
Aug 31st, 2008, 1:11am
 
I've managed to get ruby-processing running happily on my mac (excellent stuff jashkenas).   What I'd like to be able to do is source data that I'm displaying in processing from a MySQL database.

I'm very familiar with active record (using MRI ruby) so it would be great if I could use it (familiarity and all that) inside ruby-processing. However, this is my first foray into jruby and I can't work out how to do this.  I think I've got the requisite gems installed on my machine:

activerecord (2.1.0)
activerecord-jdbc-adapter (0.8.1)
activerecord-jdbcmysql-adapter (0.8.1)
activesupport (2.1.0)
jdbc-mysql (5.0.4)

But I can't work out how to require activerecord into my app inside the samples directory.  I've tried all combinations of:

require 'rubygems'
require 'activerecord'
load_ruby_library "rubygems"
load_ruby_library "activerecord"

and it's not able to find the darn things - sob.  Has anyone tried this and if so any pointers would be gratefully received.

Cheers

Rupert


Re: ruby-processing & active record
Reply #1 - Sep 1st, 2008, 7:43pm
 
solved *phew*

bad form I know following myself up - but after ending up having to work in the Java world to access my databases the pain got too much so I managed to crack the nut of using ActiveRecord within ruby-processing.

For now it's sitting in my git account (only just got it up there):

http://github.com/rupert/ruby-processing

there's an active_record_for_ruby_processing folder within the library folder.This contains activerecord and activesupport from rails 2.1.0 together
with the hacks needed to get it to work and a database.yml file for
the configuration as per rails-sylee.

I've also added a sample to the samples folder which uses it.

Otherwise it's as per Jeremy's current master on github.  I've only just mailed Jeremy about it so haven't updated the ruby-processing wiki yet, but will add something there soon.

Cheers

Rupert
Re: ruby-processing & active record
Reply #2 - Sep 12th, 2008, 8:10pm
 
This is fantastic, rupert, thanks for posting this. I'm thinking about building a bit of a framework on ruby-processing, with more convention over configuration, and some other neato-features too. I hate that you have to configure so much to get anything drawn... the Rails world would seem to have a lot to offer ruby-processing. Also i'm thinking of adding natural-language color naming, like:

fill :bright_green
stroke :dark_grey

and fonts like:

font :garamond

or perhaps allowing people to configure defaults in a YAML file, even class-based ones as a kind of CSS... you could establish some styles and assign them to primitives with inheritance etc.

Seems like a lot could come of this, not least that in theory one could run a console-like Ruby interpreter in there and allow users to code directly into an app.
Re: ruby-processing & active record
Reply #3 - Nov 7th, 2009, 12:42pm
 
The link no longer works and the github account no longer seems to exist. Google can't find it either. Anyone have a link or copy for this? Looks interesting.
Re: ruby-processing & active record
Reply #4 - Jan 12th, 2010, 9:43pm
 
I got this working with sqlite btw. The key is using the right connection adapter (use the current jruby one). Here's some example code:

Code:

load_libraries 'active_record', 'jdbc-sqlite3'

# connect to database.  This will create one if it doesn't exist
MY_DB_NAME = ".my.db"
MY_DB = SQLite3::Database.new(MY_DB_NAME)

# get active record set up
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => MY_DB_NAME)
Page Index Toggle Pages: 1