Rails 3.1 include CoffeeScript, jQuery, Sass as default

Posted on by tkwong

This gallery contains 3 photos.

Yes, the coming Rails 3.1 is going to be bring new library as default: CoffeeScript, jQuery, and Sass.

In true Ruby and Rails style, there’s been a little controversy over today’s CoffeeScript and Sass news. While the jQuery migration was pretty much accepted due to Prototype’s position six feet under, plenty of developers are familiar with JavaScript and either feel slighted by CoffeeScript’s inclusion as a default or are concerned that it’ll act as a barrier for newcomers to Rails in future.

Given that you can “opt out” of having CoffeeScript and Sass included in your Rails projects by making a minor change to your Gemfile, this faux-controversy is nowhere near as interesting to me as the legitimate RSpec vs Test::Unit debate that DHH kicked off.

However, if you want to grab some popcorn and enjoy the bullshit, the comments on this GitHub commit page are epic. People have even gone so far to produce graphics to express their opinions. Rock and roll. There’s also a significant level of pie-slinging going on on Twitter too. lets quickly go through the details now.

jQuery – Trivial

A lot of Rails applications lean on JavaScript to provide client-side and AJAX functionality. Till now, the Prototype library had been included in Rails by default as a way to make various things easier to achieve across different browsers, but jQuery has become significantly more popular over the last few years.

Given this, DHH’s announcement passed with little controversy since Rails developers had become used to using jQuery and installing the jquery-rails gem anyway. A good move and a progression with the times – awesome.

CoffeeScript – JavaScript, Improved

CoffeeScipt, which may be new to all. From CoffeeScript : CoffeeScript is a little language that compiles into JavaScript. If started life as a Ruby project that converted a cleaner, JavaScript-esque language into JavaScript. CoffeeScript’s syntax enables you to write JavaScript in a cleaner and, often, more logical way.

Sass – CSS (yes) – HAML – HTML (no)

Sass is to CSS as CoffeeScript is to JavaScript, though to a less extreme level. In its modern form, Sass looks just like CSS but adds support for things like variables, functions, nesting, and similar useful features. Crucially, Sass is just a superset of CSS so you can still use regular CSS with Sass and it’ll Just Work™. You can then learn new features one by one and start using them as you like (I must admit, I’m a massive fan of Sass and I mostly stick to the variables and nesting features).


How to Play with Rails 3.1, CoffeeScript and All That Jazz Right Now