Skip to content

Instantly share code, notes, and snippets.

@cristibalan
Created January 25, 2011 04:12
Show Gist options
  • Save cristibalan/794494 to your computer and use it in GitHub Desktop.
Save cristibalan/794494 to your computer and use it in GitHub Desktop.
# include bundled assets if not in development
# this allows us to deploy without installing jammit
module JammitHelper
def include_stylesheets(*packages)
return super if Rails.env.development? || Rails.env == 'test'
options = packages.extract_options!
files = asset_tags(:css, packages)
files.push(options) unless options.empty?
stylesheet_link_tag(*files)
end
def include_javascripts(*packages)
return super if Rails.env.development?
javascript_include_tag(asset_tags(:js, packages))
end
def asset_tags(ext, packages)
packages.map do |package|
source = "assets/#{package}.#{ext}"
path = Rails.root.join("public", source).to_s
mtime = File.mtime(path).to_i.to_s
"/#{source}?#{mtime}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment