Rod McLaughlin

The Ruby on Rails 'asset pipeline' makes your site behave differently on the WWW from locally (13 dec 12)

The 'asset pipeline' is an idea introduced in Rails 3.0. It make Rails faster in production, by putting Javascript and CSS together, in files whose name is a hash of their contents, eg. 5ee62915cef135628590fd6a41f47dd7.js.

This means the browser only needs download and execute the file when the Javascript changes - otherwise it can keep a cache of it. So far, so good.

The only problem is when you try to put your site into production.

It doesn't work.

It worked in development and test, but in production, it forgets to load eg. prototype.js, which every other Javascript library

(eg. needs.

One can find a wealth of advice on how to prevent this problem. 

config.assets.compile = true

(or is it 'false'?) in config/environments/production.rb

Or how about

bundle exec rake assets:precompile ?

That didn't work either.

Currenly, I have the Calendar working in Firefox, but not in Safari.



Got it - instead of all that 'javascript_include_tag' nonsense, I put

<script src=
at the top of application.html.erb

where file 



Now the calendar pops up. But it writes eg. 'December 13th 2012' in the box instead of '12/13/2012' - the line 

  <% CalendarDateSelect.format = :american %>

isn't being read for some reason.

It was easier to write code to parse the new date format than figure it out:

Date.parse( 'December 13th 2012' ).to_s => '2012-12-13'

'2012-12-13' can be written into a MySql datetime column from Rails.


Portland London