config.assets.compile=true in Rails production, why not?

The default Rails app installed by rails new has config.assets.compile = false in production. And the ordinary way to do things is to run rake assets:precompile before deploying your app, to make sure all asset pipeline assets are compiled. So what happens if I set config.assets.compile = true in production? I wont’ need to run … Read more

rails 3.1.0 ActionView::Template::Error (application.css isn’t precompiled)

I made a basic rails app with a simple pages controller with an index function and when I load the page I get: ActionView::Template::Error (application.css isn’t precompiled): 2: <html> 3: <head> 4: <title>Demo</title> 5: <%= stylesheet_link_tag “application” %> 6: <%= javascript_include_tag “application” %> 7: <%= csrf_meta_tags %> 8: </head> app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__43625033_88530400′ Gemfile source ‘http://rubygems.org’ gem … Read more

Using fonts with Rails asset pipeline

I have some fonts being configured in my Scss file like so: @font-face { font-family: ‘Icomoon’; src: asset-url(‘icoMoon.eot?#iefix’, font) format(’embedded-opentype’), asset-url(‘icoMoon.woff’, font) format(‘woff’), asset-url(‘icoMoon.ttf’, font) format(‘truetype’), asset-url(‘icoMoon.svg#Icomoon’, font) format(‘svg’); } The actual font file are stored in /app/assets/fonts/ I have added config.assets.paths << Rails.root.join(“app”, “assets”, “fonts”) to my application.rb file and the compile CSS source … Read more

How can I disable logging of asset pipeline (sprockets) messages in Ruby on Rails 3.1?

Sprockets tends to be quite verbose in the (dev) log by default under Ruby on Rails 3.1 (RC1): Started GET “/assets/application.css” for 127.0.0.1 at 2011-06-10 17:30:45 -0400 Compiled app/assets/stylesheets/application.css.scss (5ms) (pid 6303) Started GET “/assets/application.js” for 127.0.0.1 at 2011-06-10 17:30:45 -0400 Compiled app/assets/stylesheets/default.css.scss (15ms) (pid 6303) … Started GET “/assets/default/header_bg.gif” for 127.0.0.1 at 2011-06-10 17:30:45 … Read more

Using Rails 3.1, where do you put your “page specific” JavaScript code?

To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file. This sounds like a real life-saver, but I am a little concerned about page-specific JavaScript code. Does this code get executed on every page? … Read more

Rails 4: how to use $(document).ready() with turbo-links

I ran into an issue in my Rails 4 app while trying to organize JS files “the rails way”. They were previously scattered across different views. I organized them into separate files and compile them with the assets pipeline. However, I just learned that jQuery’s “ready” event doesn’t fire on subsequent clicks when turbo-linking is … Read more