Ruby on Rails

Install Redmine on CentOS

Redmine website is http://www.redmine.org/.

Install and setup prerequisites

We will need Ruby, Ruby on Rails, Git, etc. The current Redmine (0.9.3) requires Ruby 1.8.7 or 1.8.6, And RoR 2.3.5.  

Libraries

# yum install autoconf automake zlib zlib-devel

 

GIT and Subversion

We need git and svn for various installation:

# yum install git subversion

(or "apt-get install", "emerge", etc)

Install Ruby on Rails 2.1

Install RoR 2.1

Download the source package from http://www.ruby-lang.org/en/downloads/, unpack the tar.gz file, and follow the README file.

Rubygem

Download from RubyGems, extract it, and run "sudo ruby setup.rb".

Then you can start the gem server by calling "gem server". And you can view the server via http://localhost:8808.

Use Callbacks to Manipulate an ActiveRecord Object's has_many Associates

Say you have an ActiveRecord that has many categories:

class Article < ActiveRecord::Base
    has_many :categories
end

If you want to load the categories when the article is initialized, or if you want to save the categories when the article is saved, don't try to override "initliaze" or "save" methods. Use the callback functions in ActiveRecord::Callbacks.

RDoc Error: Directory doc already exists

In my Rails application direcotory, when I run "rdoc", I got an error message:

Directory doc already exists, but it looks like it
isn't an RDoc directory. Because RDoc doesn't want to risk
destroying any of your existing files, you'll need to
specify a different output directory name (using the
--op <dir> option).

That's because rails generated "doc" directory that rdoc don't like. To fix this, we can either use rake:

$ rake doc:app

Or specify another directory name to rdoc:

$rdoc --op rdoc_dir

Setup Ruby on Rails behind Apache

Here are some of the ways to run Ruby on Rails behind Apache.

Apache + mod_fcgid

Reference Howto Setup Apache With FastCGI And Ruby Bindings.

Apache mod_fcgid

Make sure mod_fcgid is available, if not, install it
# emerge -pv www-apache/mod_fcgid

Ruby fcgi

I was not able to install it via gem. See error below:

Checking Rails Project into Subversion

The book "Rails Cookbook" has a wonderful section on "Getting Your Rails Project into Subversion".

In short, here are the steps:

Install Ruby on Rails 2.0 on Gentoo

Install RoR 2.0

At this date, Ruby on Rails 2.0 is the latest greatest RoR, which is not available in Portage yet.

Ruby language

If you want to install the ruby from source, then download the source from http://www.ruby-lang.org/en/downloads/.

Or, you can use emerge:

# emerge -pv  dev-lang/ruby