Good thing the intertubes still are delivering vital hints even during this bleak times… I was trying to use ActiveRecord inside a small script of mine and I ran into some issues. I’m using OSX 10.5.6 “Leopard” and MacPorts.
First I needed to install activerecord, easy:
sudo gem install activerecord
I used mac port to install mysql:
sudo port install mysql5 +server
now the triky part, installing the mysql gem. First download and modify the mysql gem:
sudo gem install mysql
this will fail. Now you need to navigate to the gem cache dir:
cd /opt/local/lib/ruby/gems/1.8/cache
then unpack the gem
sudo gem unpack mysql-2.7.gem
cd mysql-2.7
with your favourite editor add this line to mysql.c.in
#define ulong unsigned long
now rebuild the gem and install it
sudo gem build mysql.gemspec
sudo mv mysql-2.7.gem ../mysql-2.7-CUSTOM.gem
Almost there, we need to install our shiny-new gem:
sudo env ARCHFLAGS=”-arch i386″ gem install mysql-2.7-CUSTOM.gem — \
–with-mysql-config=/opt/local/bin/mysql_config5
Ok, all is done (u might need to install some missing parts) now all you need to do is to add some requires to your script and remember to always establish a connection before using any ActiveRecord resources:
require ‘rubygems’
require ‘active_record’…
dbConfig = {“adapter” => “sqlite3″, “dbfile” => ‘./file.db’}
ActiveRecord::Base.establish_connection(dbConfig)
…
class Stuff < ActiveRecord::Base
…
Hope somebody finds this usefull!
dArio
[thanks to kpumuk.info/ and http://www.kudelabs.com/2008/09/12/installing-mysql-gem-on-macos-x-leopard ]


