sprockets

Using Rails 3.1 assets pipeline to conditionally use certain css

僤鯓⒐⒋嵵緔 提交于 2019-11-26 13:53:15
I’m in the process of building my first solo Rails app using Rails 3.1.rc5. My problem is that I want to have my site render the various CSS files conditionally. I’m using Blueprint CSS and I’m trying to have sprockets/rails render screen.css most of the time, print.css only when printing, and ie.css only when the site is accessed from Internet Explorer. Unfortunately, the default *= require_tree command in the application.css manifest includes everything in the assets/stylesheets directory and results in an unpleasant CSS jumble. My current workaround is a sort of brute-force method where I

Rails 3.1 asset pipeline: how to load controller-specific scripts?

独自空忆成欢 提交于 2019-11-26 12:38:30
If I generate a new controller in Rails 3.1, also a javascript file with the name of the controller will added automatically. Firstly, I thought this javascript file will used only, when the related controller is called. By default there is the instruction //= require_tree . in the application.js -file, that include every javascript file on it's tree. How could I load only the controller specific script? Nguyen Chien Cong To load only the necessary name_of_the_js_file.js file: remove the //=require_tree from application.js keep your js file (that you want to load when a specific page is loaded

Rails 3.1 asset pipeline and manually ordered Javascript requires

痞子三分冷 提交于 2019-11-26 12:22:54
问题 I am trying to convert an existing app to the new 3.1 asset pipeline layout, and want to include a lot of vendor files that have to be in a specific order, (underscore.js and backbone being one pair). As such, I can\'t just use a = require_tree . to pull in my vendor files, (without renaming each file with a prefix. Yuck). The following is within my app/assets/javascripts/application.js file: //= require modernizr-1.7 //= require jquery-1.6.1 //= require underscore-1.1.5 //= require backbone

How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?

我与影子孤独终老i 提交于 2019-11-26 11:26:25
Sprockets tends to be quite verbose in the (dev) log by default under 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 -0400 Served asset /default/header_logo.gif - 304 Not Modified (7ms) (pid 6303) Served asset /default/header_bg.gif - 304 Not

How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?

六月ゝ 毕业季﹏ 提交于 2019-11-26 05:52:14
问题 Sprockets tends to be quite verbose in the (dev) log by default under 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 -0400 Served asset

Using Rails 3.1 assets pipeline to conditionally use certain css

不羁岁月 提交于 2019-11-26 03:46:25
问题 I’m in the process of building my first solo Rails app using Rails 3.1.rc5. My problem is that I want to have my site render the various CSS files conditionally. I’m using Blueprint CSS and I’m trying to have sprockets/rails render screen.css most of the time, print.css only when printing, and ie.css only when the site is accessed from Internet Explorer. Unfortunately, the default *= require_tree command in the application.css manifest includes everything in the assets/stylesheets directory

Rails 3.1 asset pipeline: how to load controller-specific scripts?

大憨熊 提交于 2019-11-26 03:01:43
问题 If I generate a new controller in Rails 3.1, also a javascript file with the name of the controller will added automatically. Firstly, I thought this javascript file will used only, when the related controller is called. By default there is the instruction //= require_tree . in the application.js -file, that include every javascript file on it\'s tree. How could I load only the controller specific script? 回答1: To load only the necessary name_of_the_js_file.js file: remove the //=require_tree

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

可紊 提交于 2019-11-26 01:26:33
问题 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? The last thing I want is for all of my objects to be instantiated for every page when they are only needed on 1 page. Also, isn\'t there potential for code that clashes too?