Sunday, January 20, 2008

Nuovi Anni a Torino, Italia

Yea.... still keeping it real at Piazza San Carlo in Torino, Italia on New Year's eve.

Thursday, January 17, 2008

Ruby Captcha

So I wanted to get a captcha rolling in Ruby on Rails. I decided to use recaptcha because Luis's research is so cool. The tutorial for Ruby recaptcha is fine, but I would have liked an explicit example of what would be in environment.rb. do |config|
RCC_PUB = '...' #Public key from recaptcha registration
RCC_PRIV = '...' #Private key from recaptcha registration

Finally, I had to restart Webrick for those variables to take effect.

Installing Mongrel on a Linux box

So I wanted to run Mongrel on a linux box in which I did not have root authority.

My configuration
  1. ruby 1.8.5 (2006-08-25) [i386-linux]
  2. gem version 0.9.4
Simply run:
gem install mongrel -i [dir_you_can write_to] (You may have to run this twice if the first invocation gives an error)

You will see something like:
Select which gem to install for your platform (i386-linux)
1. mongrel 1.1.3 (java)
2. mongrel 1.1.3 (i386-mswin32)
3. mongrel 1.1.3 (ruby)
4. mongrel 1.1.2 (ruby)
5. mongrel 1.1.2 (mswin32)
6. mongrel 1.1.2 (java)
7. Skip this gem
8. Cancel installation

I picked 3. Hopefully this works with out a problem.

You will also need:
gem install rails -i [dir_you_can write_to]

In the
[dir_you_can write_to], you will find bin/mongrel_rails.
Go to your directory containing the rails application and run

[dir_you_can write_to]/bin/mongrel_rails.
After invoking this, I received the following error message:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:303:in `report_activate_error': Could not find RubyGem mongrel (> 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:237:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:75:in `active_gem_with_options'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'

The solution for this is to set GEM_PATH like so:
export GEM_PATH=/non_default_gems_install/ruby_gems

Try running this again

[dir_you_can write_to]/bin/mongrel_rails start -p 8000

Open a browser pointing it to server:8000 should display the rails application.

Wednesday, January 16, 2008

Getting Ruby on Rails up and running in Eclipse

So I'm running on a MacBook running Leopard and wanted to do some Ruby on Rails development using Eclipse. Here is what I did.

  1. Follow the tutorial for installing the base libraries for the following components
    • Ruby
    • RubyGems
    • Ruby on Rails
    • FastCGI
    • You will need MySQL, but this tutorial is OSX specific
    • MySQL Native Bindings
  2. Download and install Eclipse.
  3. Open Eclipse and install the following plugins.
    • Aptana plugin
    • Ruby Development Tools plugin (pick the release version) (OPTIONAL as of 6/9/2008)
    • Subclipse plugin
    • Somewhere in the process I ran into a problem involving Mylyn. Well go ahead and install that as well.
  4. Open Eclipse, open the Help drop down and click on Aptana Start Page. In the center column you will see the Aptana Ruby on Rails plugin. Go ahead and install it.
  5. Now you should easily be able to create a Rails project within Eclipse.