Skip to content

Instantly share code, notes, and snippets.

@between40and2
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save between40and2/ee9c64da8c18a2a5f47b to your computer and use it in GitHub Desktop.
Save between40and2/ee9c64da8c18a2a5f47b to your computer and use it in GitHub Desktop.
Rails Assets Pipeline Tips

Problems

Guides suggests us to bundle design assets into a plugin/engine. But it does not tell us clearly how to import it in hosting app.

Solution.

in config/application.rb

assets.prepend_path '../../../zn/rails/zn_site/app/assets/stylesheets'
puts "assets.path : #{assets.paths}"

in app/assets/stylesheets/application.css

 *= require 'site-footer'
 *= require_directory '../../../../../../zn/rails/zn_site/app/assets/stylesheets/zn_site'

Note that require_directory and require_tree only take relative path (from application.css not other places like host root)

See in source code

Refs

By the way, do not forget the origins

The reason that application.js is chosen, is because your layout says so. In your typical layout view, you will see something like

stylesheet_link_tag 'application'

which (stylesheet_link_tag) is defined in ActionView::Helpers::AssetTagHelper

You are free to add more lines like this to include other css files. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment