rod mclaughlin


Moving to Rails 3.1 (05 aug 11)

Rails 3.1 release candidate 5 is the latest

Here's how do a simple app using RVM on Linux Ubuntu 10 64 bit:

$ rvm install 1.9.2-p0
$ rvm use 1.9.2-p0
$ rvm gemset create rails310
$ rvm 1.9.2-p0@rails310
$ gem install rails --pre
$ rails new new
$ cd new
# Edit Gemfile: add line gem 'rails', '>=3.1.0.rc1' and remove any other 'rails' lines in it
$ bundle install
$ rails server &
# Point your browser to http://localhost:3000

See also

http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate

http://beginrescueend.com/rvm/


One of the problems with Ruby on Rails is it develops so fast its developers don't have time to write documentation. If you think my post (above) is obscure, how about this explanation of 'Sprockets', which is apparently an important part of Rails 3.1, given by its author:

"Sprockets 2 is a Rack-based asset packaging system that concatenates and serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS"

https://github.com/sstephenson/sprockets

This is a bit better:

http://www.xydo.com/toolbar/18039833-using_sprocket_2_in_rails_with_coffeescript_and_sass


Aug 30 - Rails 3.1 has been released. So I changed the Gemfile to say

  gem 'rails', '>=3.1.0'

instead of

  gem 'rails', '>=3.1.0.rc1'

ran 'bundle install' to install Rails 3.1 then 'rails server' and it no longer worked. It said

'autodetect': Could not find a JavaScript runtime. 
See https://github.com/sstephenson/execjs for a list
of available runtimes. (ExecJS::RuntimeUnavailable)

This is an issue I had when Rails 3.1 was beta: http://rubyjunction.com/moving-to-rails-3-1-beta

So I tried adding

  gem 'therubyracer'

to the Gemfile and ran 'bundle install' again

That was an inspired guess, as it transpired

'rails server' now runs a Rails server, like its supposed to

For the interested, here is the Gemfile:


source 'http://rubygems.org'

gem 'rails', '>=3.1.0'

gem 'therubyracer'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'
# gem 'arel',      :git => 'git://github.com/rails/arel.git'
# gem 'rack',      :git => 'git://github.com/rack/rack.git'
# gem 'sprockets', :git => "git://github.com/sstephenson/sprockets.git"

gem 'mysql'

# Asset template engines
gem 'sass', '~> 3.1.0.alpha'
gem 'coffee-script'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

 



Back
Portland London