Using CoffeeScript with Rails

Ruby on Rails is a popular server-side framework for web applications. Rails has recently adopted first-class support for CoffeeScript, making it the preferred choice for client-side code in Rails applications. Rails uses an asset pipeline to compile CoffeeScript (among other things). This is some code that takes assets such as scripts and style sheets, and compiles and prepares them for consumption by a browser. We'll walk through the steps to get your CoffeeScript running smoothly in Rails with the asset pipeline, and we'll port our pet shop application to Rails to try it out.

Setting up the asset pipeline

The steps we'll need to follow depend on which version of Rails we are working with, and whether it is a new ...

Get CoffeeScript Application Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.