Javascript and CSS specific files, how to include them by convention ? Rails 3.1 -


how can include specific js or css files (by convention ?) ruby rails 3.1 ?

i have view : views/project/index.html.erb

and want include specific javascript file page. put in assets/javascripts/project/index.js

same view : home/index.html

thanks

in application.css , application.js file, sure remove line \\= require tree.

then, manually list css/js files want included in each manifest file, example:

// application.js //= global.js //= everywhere.js 

then, setup yield in header or closing body tag application layout file, instance (in haml)

%head   %title page   = stylesheet_link_tag 'application'   = yield :stylesheets 

then in particular view, _example_partial.html.haml, this:

- content_for :stylesheets   = stylesheet_link_tag 'example_partial'  -# rest of view goes here 

you exact same thing javascript files, using javascript_include_tag instead of stylesheet_link_tag.

this let , assemble view-specific javascript / css payloads. there may more sophisticated way handle using asset pipeline, suggest if asset pipeline minifying , merging major stylesheets kind of +1 css / js file per view not going cause major performance hit. try make sure don't overdo dozens of separate files loading single view.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -