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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.