How to play with Rails 3.1 on Ubuntu with RVM
RubyInside blog also published an excellent tutorial on how to play with Rails 3.1 right now. Read it first, I will not explain everything here, but I had 2 problems following the how-to.
First, install rails master branch (I use the awesome hub wrapper for git) :
cd ~/code git clone rails/rails
Then create a gemset with RVM :
rvm use 1.9.2@yourapp --create gem install i18n thor bundler
Then we can create our rails app:
./rails/bin/rails new yourapp --edge cd yourapp
Unfortunately, I had 2 problems with this application.
rails binary installed in $GEM_HOME/bin is not fully functional :
% rails -v /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError) from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems.rb:219:in `activate' from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems.rb:1065:in `gem' from /usr/local/rvm/gems/ruby-1.9.2-p180@yourapp/bin/rails:18:in `<main>'
The simplest way to solve this is a shell alias:
% alias rails=$GEM_HOME/bundler/gems/rails-*/bin/rails % rails -v Rails 3.1.0.beta
With this, I could make the application run, with SASS support, good.
But CoffeeScript didn’t work. When I tried to introduce an
the following error instead of a normal
Ubuntu user, I have none. I tried to install
mustang, but 1/ it took a very long time (compilation of native code
on a netbook), 2/ it led me to other errors I had not been able to understand. The simplest way I found to get a working JS runtime is the
nodejs package of the distribution:
% sudo aptitude install nodejs
Restart the Rails server, and everything should work smoothly now!
You can forget the advices in the CoffeeScript section, the application.js is already good with
//= require blah at the beginning.
One last thing, you should note this Rails version is pre-beta. Some things may not work. For instance, the scaffold generators gives you an
// instead of
#, resulting in
this kind of errors:
Error: Parse error on line 1: Unexpected 'MATH'
Don’t know if it’s a Rails or ExecJS bug though. But the conclusion is the same: use with caution.
I’m really excited with the upcoming features in Rails 3.1, particularly automatic reloading and engines support. It was pretty fun to see all this rage around CoffeeScript and SASS, both seem nice, productive, and are easy to disable. I can’t wait to try a RC version !