Archive for the 'rails' Category

Installing Ruby In Your Home Folder On Dreamhost

Thursday, November 22nd, 2007

I wanted to install a more recent ruby on my dreamhost hosting, with more recent gems then provided standard, so I decided to install ruby in my home directory. Below the steps I took to get it working. It worked out of the box for me, so now, I have full control over which exact gems and versions I use, independent of what dreamhost provides.

First, download the ruby tar ball:
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
(note: be sure to check on the ruby site to get the latest stable sources, in the mean time, newer patchlevels might be available)

untar the tar ball:

tar -xvf ../ruby-1.8.6-p110.tar.gz

In your home folder, create a ruby directory to hold the installation:

mkdir ~/ruby

Change directory to the untarred directory. In that directory, run configure pointing to your local ruby directory:

./configure –prefix=/home/username/ruby

Then run:

make
make install

You now should have a ruby installation in /home/username/ruby.

In your home folder, edit your .bash_profile file and add the ruby bin folder to your path:

export PATH=”$HOME/ruby/bin:$PATH”

Source this file and run ruby -v

source ~/.bash_profile
ruby -v

SUCCESS:
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-linux]

Next, install ruby gem, the ruby package manager. Ruby gems can be found here

Get the latest version:

wget http://rubyforge.org/frs/download.php/28174/rubygems-0.9.5.tgz

untar:

tar -xvzf rubygems-0.9.5.tgz

cd rubygems-0.9.5

ruby setup.rb (note, be sure that you have your home backed ruby in your path!!)

Install rake:

gem install –remote rake

gem install fcgi

Do not forget to update the shebang in the dispatcher.fcgi file to the correct path

#!/home/username/ruby/bin/ruby

Then, install rails:

gem install rails

And you are rolling!!!

Note that in order to deploy in production mode, you need to uncomment the ENV[’RAILS_ENV’] ||= ‘production’ line in environment.rb.

Below the deployment recipe I used:


ssh_options[:paranoid] = false
set :user, 'user'
set :password, 'passwd'
set :application, "app"
set :repository, "http://url_to_svn_repository"
set :deploy_to, "/home/username/www.killerapp.com"

role :app, "www.killerapp.com"
role :web, "www.killerapp.com"
role :db, "www.killerdb.com", :primary => true

set :checkout, "export"

namespace :deploy do
desc "Restart the FCGI processes on the app server as a regular user."
task :restart, :roles => :app do
run "#{current_path}/script/process/reaper --dispatcher=dispatch.fcgi"
end

end

Thanks to Geoffrey Grosenbach for getting the inspiration for this recipe.

Hope this helps.

Stacked Bar Graph in Rails

Saturday, April 21st, 2007

A while ago, I stumbled upon some nice ccs-graphs that did precisely what I needed at work. I wanted to show the evolution of some stats over time, in stacked-bar format. After some googling, I found a simple rails helper for css graphs. I needed some more stuff, but is was definitely a very good starting point.

The final graph I wanted to have looks something like this:

  • 38
  • 29
  • 36
  • 28
  • 34
  • 27
  • 32
  • 26
  • 30
  • 25
  • 28
  • 24
  • 26
  • 23
  • 24
  • 22
  • 22
  • 21
  • 20
  • 20

(more…)


Close
E-mail It
Socialized through Gregarious 42