JQUERY Ninja - Switching to alternative stylesheet using Ruby on Rails

On page 81 of the ‘JQuery - Novice to Ninja’ book, we are taught how to link to and switch to another stylesheet if the size of the browser window is changed. This works great in html, but I’m trying to use it in a Rails app.

When I declared the ‘base’ stylesheet my Rails app in the head, I wrote:

<&#37;= stylesheet_link_tag 'base', :media => 'screen' %>

. However, I can’t seem to use Ruby code like this when trying to apply the new ‘wide’ stylesheet in the .js file.

Here’s the javascripy code that I need to use in a Rails file:

if ($('body').width() > 900) { $('<link rel="stylesheet" href="wide.css" type="text/css" />')
.appendTo('head'); } else {
$('link[href=wide.css]').remove();
}