Tuesday, September 23, 2008

Getting jruby running with mysql on ubuntu

You want to get jruby running quickly on ubuntu using mysql as a backing store?

Unfortunately, it does not "just work" with sqlite3 out of the box on ubuntu for some reason. I don't really care why, as mysql is very easy to setup. The most important step that flexed my googling muscles was setting the database adapter to jdbcmysql in the database.yml file.

I will post later on a howto to get this working with glassfish and war files. For some reason, warbler nor goldspike "just work" on ubuntu either.

# install mysql
sudo apt-get install mysql-server mysql-client libhtml-template-perl mailx dbishell libcompress-zlib-perl mysql-doc-5.0 tinyca

# install ant and jdk
sudo apt-get install ant sun-java6-jdk

# install jruby
cd software
wget http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz
tar xvfz jruby-bin-1.1.4.tar.gz
ln -s jruby-1.1.4 jruby
export PATH=$PATH:$HOME/software/jruby/bin

# install the version of rails wanted by jruby
jruby -S gem install jruby-openssl
jruby -S gem install rails

# list your gems
jruby -S gem list

# install the gems needed for db
jruby -S gem install activerecord-jdbc-adapter activerecord-jdbcmysql-adapter

# generate some code
cd ~/scripts/ruby
jruby -S rails wherehaveyoubeen -d mysql
cd wherehaveyoubeen
jruby script/generate controller states index

# configure access to the database server
vi config/database.yml

# adapter: jdbcmysql <- very important!
# encoding: utf8
# database: wherehaveyoubeen_development
# username: root
# password: database
# socket: /var/run/mysqld/mysqld.sock

# generate the db
jruby -S rake db:create:all
jruby -S rake db:migrate

# edit your app
sudo apt-get install emacs ruby-elisp irb1.8 emacs22-el
emacs -bg black -fg wheat app/views/states/index.html.erb

# uncomment the secret in app/controllers/application.rb
vi app/controllers/application.rb

# run your app
jruby script/server

# go to your app

Monday, September 22, 2008

Adding subversion to eclipse on linux (ubuntu)

You want to use subversion in eclipse? You will need a javahl implementation.

Ubuntu has a javahl package:

sudo apt-get install libsvn-java

Then add this to your eclipse.ini: