Wednesday, April 29, 2009

Installing Rails on Ubuntu 9.04

Just installed Ubuntu 9.04 (released Apr 23, 2009) on my work laptop. Here are all the things I needed to do to get a Rails environment working. One additional complication is that I use Heroku to deploy. Install non-default Ubuntu packages
  • mysql-client & mysql-server
  • ruby
  • git, svn, cvs, & integration with git (git-svn, git-cvs)
  • sun-jdk 6 (for eclipse)
  • lynx, wget, curl
Install RubyGems Once the base ruby package is installed, all the rest of the ruby/rails stuff is installed via sudo and tar.gz download. In this case,
  • download the latest Ruby Gems tarball from http://rubygems.org/
  • untar
  • cd into the directory
  • run: ruby setup.rb
  • make a symbolic link to gem1.8: cd /usr/bin; sudo ln -s gem1.8 gem
Install Rails
  • sudo gem install rails
Install Heroku
  • sudo gem install heroku
If this error results, then install ruby1.8-dev
  • sudo apt-get install ruby1.8-dev
Running Heroku Running heroku for the first time will probably get an error because libopenssl_ruby isn't installed
  • sudo apt-get install libopenssl-ruby
Creating a MySQL database via rake Invoking "rake db:create" in the new Rails app directory will probably get this error: "sudo gem install mysql" will cause another set of errors. That's because libmysqlclient5-dev is not installed. I tried installing it on the command line via "sudo apt-get install libmysqlclient5-dev" but that didn't work. However, the Synaptic Package Manager did the right thing.
  • sudo gem install mongrel
Lastly, if the mongrel gem is not installed, then running rails will fire up WebBrick.
  • sudo gem install sqlite3-ruby
causes this error: The fix is to install libsqlite3-dev
  • sudo apt-get install libsqlite3-dev
and that should allow sqlite3-ruby to install properly.

Labels: , , ,

Monday, April 27, 2009

Using Ruby oauth gem to access Netflix

The example at Mandarin Soda didn't work for the latest version of the Ruby oauth gem (version 0.3.2.2 as of this writing). Took me a day to work out all the differences. The slightly alter code is a gist on GitHub (and reproduced here). The differences are:
  • :request_token_url is http instead of https
  • access_token.response is a subclass of Net::HTTPResponse so there's no access_token.response[:user_id]; rather, you get the user ID with access_token.params[:user_id]
  • using access_token.get(url) instead of consumer.request(:get, url, access_token, {:scheme => :query_string}) but I think they're the same (and the latter still works)
Link

Labels: , ,