The Altruist

The Altruist’s position presents him with opportunities not normally present. He shares the benefits, so that the lives of those whom he protects will be enriched.

Installing RailsCollab

Written by Adrian Goins on Mar 11, 2011 in Ruby

I'm installing RailsCollab for project management, and it's not without its share of hurdles to overcome.

Problem: no such file to load -- initializer

It's a Rails 2 application.  If you're installing it with Passenger and have Rails 3 installed, you'll need to designate that it needs Rails 2 by changing adjusting environment.rb:

#RAILS_GEM_VERSION = '>=2.3.3' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION

I don't have any other Rails apps running on this system yet, so I removed Rails 3 completely.

Problem: Missing gems

The INSTALL doc doesn't give you all of the information about the gems you need to install.  Here's the final list, including the "optional" gems that you are required to have before the app will run:

  • rails-2.3.8
  • icalendar
  • RedCloth
  • ruby-openid
  • ferret
  • acts_as_ferret-0.4.4
  • actionmailer
  • rspec
  • aws-s3
  • mysql
  • sqlite3

I particularly enjoyed having to install sqlite3 when we're using MySQL.

Problem: no database.yml.template

The author expects that you'll run this out of sqlite3.  If you'd like to use MySQL instead, here is a template for the production portion:

production:
adapter: mysql
encoding: utf8
database: dbname
username: dbuser
password: dbpass
host: dbhost

Problem: Apache can't write to directories

You'll find that Passenger won't start because it can't write to certain directories within the app.  If your app is running as the user nobody, you'll have to change the permissions as follows:

# cd <railscollab directory>
# chown nobody log
# chown nobody tmp

Problem: uninitialized constant ActiveSupport::Dependencies::Mutex

This is a problem in Rails 2.3.8.  As of this writing, if you update to 2.3.11 this will sort itself out.

Problem: no such file to load -- sqlite3

I mentioned this above but want to mention it again here.  Even if you're not using sqlite3, the app wants the gem installed.

Problem: Mysql::Error: Table 'railscollab.wiki_pages' doesn't exist:

The full error is Mysql::Error: Table 'railscollab.wiki_pages' doesn't exist: SHOW FIELDS FROM `wiki_pages` (ActiveRecord::StatementInvalid) and comes from the fact that the setup script appears to create the development databases by default.  If you want to create your content in MySQL for production, do the following before running the setup script:

# export RAILS_ENV=production

Problem: Variables visible in views

After overcoming all of these problems, I was finally granted the RailsCollab login page.  I logged in with the user information I had created, only to find that the internal content is riddled with template errors.  Pages say things like:

  • Welcome back {{user}}
  • Company card for {{company}}
  • Users who were active in last {{number}} minutes

This appears to come from locale templates not being parsed before being displayed.  After a couple of hours I traced this to the version of i18n gem installed.  Railscollab seems to want 0.4.0.  After installing 0.4.0 (and optionally removing 0.5.0 if you don't need it), add the following line to config/environment.rb:

config.gem 'i18n', :version => '0.4.0'

Problem: Running it under a subdirectory

I didn't want RailsCollab running under its own vhost, since we do a lot of proxying to internal platform-specific servers.  Configuring Passenger to operate under a subdirectory was a matter of following the directions, but the app itself had some lingering hard-coded URLs to contend with.  Rails is super dynamic, so I'm surprised that the developers left the links for the breadcrumbs hardcoded.  For each of the links in app/helpers/navigation_helper.rb I changed the link to call url_for and point to the correct controller and method.  Here's a diff you can apply to your local copy.  I'll submit it to the upstream as well to see if they want to include it in a future release.

--- navigation_helper.rb.orig   2011-03-11 10:10:30.000000000 -0500
+++ navigation_helper.rb        2011-03-11 11:07:42.000000000 -0500
@@ -51,20 +51,24 @@

def administration_crumbs
[
-      {:title => :dashboard,      :url => '/dashboard'},
-      {:title => :administration, :url => '/administration'}
+      {:title => :dashboard,      :url => "#{@template.url_for(:controller => 'dashboard', :action => 'index')}"},
+      {:title => :administration, :url => "#{@template.url_for(:controller => 'administration', :action => 'index')}"},
] + extra_crumbs + [{:title => current_crumb}]
end

def dashboard_tabbed_navigation
-    items = [{:id => :overview,       :url => '/dashboard/index'},
-             {:id => :my_projects,    :url => '/dashboard/my_projects'},
-             {:id => :my_tasks,       :url => '/dashboard/my_tasks'},
-             {:id => :milestones,     :url => '/dashboard/milestones'}]
+    items = [{:id => :overview,       :url => "#{@template.url_for(:controller => 'dashboard', :action => 'index')}"},
+             {:id => :my_projects,    :url => "#{@template.url_for(:controller => 'dashboard', :action => 'my_projects')}"},
+             {:id => :my_tasks,       :url => "#{@template.url_for(:controller => 'dashboard', :action => 'my_tasks')}"},
+             {:id => :milestones,     :url => "#{@template.url_for(:controller => 'dashboard', :action => 'milestones')}"}
+            ]
end

def dashboard_crumbs
-    [{:title => :dashboard, :url => '/dashboard'}, {:title => current_crumb}]
+    [
+     {:title => :dashboard,      :url => "#{@template.url_for(:controller => 'dashboard', :action => 'index')}"},
+     {:title => current_crumb}
+    ]
end

def project_tabbed_navigation
@@ -83,7 +87,7 @@

def project_crumbs(current=nil, extras=[])
[
-      {:title => :dashboard,           :url => '/dashboard'},
+      {:title => :dashboard,           :url => "#{@template.url_for(:controller => 'dashboard', :action => 'index')}"},
{:title => @active_project.name, :url => project_path(:id => @active_project.id)}
] + extra_crumbs + [{:title => current_crumb}]
end

In addition, you'll need to add this line to your environment.rb file:

config.action_controller.relative_url_root = "/projects"

Update: 03/12/2011

After spending the entire day yesterday installing RailsCollab and working to get it operational, I've decided to abandon it.  I corrected another 4 of the files for static URLs and sent patches to the upstream only to encounter problems that will require refactoring code to fix.  Some of the links don't work, many of the redirects that follow POST actions go to paths that end in double-slashes (like /administration//), which Rails routes can't process.

I was particularly discouraged by the fact that RailsCollab development appears to have been abandoned by its maintainer, who writes:

Right now, there isn’t any roadmap i am actively pushing for RailsCollab. Instead, i am looking to you, the users for improvements.That is, if you think there is something RailsCollab needs, then make a patch incorporating the said improvement and send it to me.

He also writes in another area that he doesn't have time to work on RailsCollab because he's working on another project that has a paid service model.

My advice is to stay away from RailsCollab and look at something with an active community and a maintainer who cares about the project.