Skip to content

TorqueBox running Rails 4

March 11, 2013

I decided to start a new web app using Rails 4, and also wanted to run it on Torquebox: my new favorite platform for Rails apps. A few hacks are required to get Rails 4 running on Torquebox.

Procedure to get Rails 4 (edge) running on Torquebox Edge

Get the latest Torquebox from the CI server: Latest Successful Build

There is an issue with Rails 4.0.0.beta1 and JRuby, so you’ll need to install the ‘edge’ gems. The issue was fixed after the 4.0.0.beta1 and will be in beta2, but beta2 has not been released at the time of this writing. You can build them yourself from source, using MRI, and then simply install them in Torquebox Jruby. I did this by switching to MRI, pulling down Rails master code, running bundle, then “rake build”. The gems are ten found in the pkg directory.

Ok, now if you attempt to create a new Torquebox app using “torquebox rails someapp”, you’ll get an error like this: “LoadError: no such file to load — rails_generator”

This is caused by some Rails version checking in the current source that falls back to Rails 2, if Rails 3 isn’t detected. Easy to hack a fix though …

Edit “torquebox-3.x.incremental.1508/jruby/lib/ruby/gems/shared/gems/torquebox-rake-support-3.x.incremental.1508/lib/torquebox/rails.rb” and change the method to look like this:

def self.using_rails3?
 ::Rails::VERSION::MAJOR == 3 || ::Rails::VERSION::MAJOR == 4
end

Last step is to edit your “Gemfile” and remove “gem ‘jruby-openssl'” because JRuby 1.7.3 includes it.

Now you should be able to deploy your Rails 4 app and run it on Torquebox successfully.

Advertisements

From → Ruby

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: