How to use Sprockets 2 with Rails 3.0.x (how to use precompiled assets)?

Josh answered me here: https://github. Com/sstephenson/sprockets/issues/151 Assets = Sprockets::Environment. New(Rails.

Root) do |env| assets = "javascripts", "stylesheets", "images", "fonts" paths = "app/assets/", "lib/assets/", "vendor/assets/" . Map{|p| assets. Map{|f| "#{p}#{f}" } }.

Flatten paths. Each{ |path| env. Append_path path } env.

Static_root = Rails.root. Join("public", "assets") end So basically, I have a rake task to precompile the assets: namespace :assets do task :precompile => :environment do Assets. Precompile(*Rails.application.config.assets.

Precompile) end end My problem was mainly to know how to request these assets. The answer is quite simple: Assets'application. Js'.

Digest Having the fingerprint, it's easy to get the filename I created helpers to include these assets: sprockets_include_tag and sprockets_image_tag Done deal (Although right now, I can't use these helpers in my stylesheets (style.css.scss. Erb)).

Josh answered me here: https://github. Com/sstephenson/sprockets/issues/151 Assets = Sprockets::Environment. New(Rails.

Root) do |env| assets = "javascripts", "stylesheets", "images", "fonts" paths = "app/assets/", "lib/assets/", "vendor/assets/" . Map{|p| assets. Map{|f| "#{p}#{f}" } }.

Flatten paths. Each{ |path| env. Append_path path } env.

Static_root = Rails.root. Join("public", "assets") end So basically, I have a rake task to precompile the assets: namespace :assets do task :precompile => :environment do Assets. Precompile(*Rails.application.config.assets.

Precompile) end end My problem was mainly to know how to request these assets. The answer is quite simple: Assets'application. Js'.

Digest Having the fingerprint, it's easy to get the filename. I created helpers to include these assets: sprockets_include_tag and sprockets_image_tag. Done deal.(Although right now, I can't use these helpers in my stylesheets (style.css.scss.

Erb)).

By the way, since then, I improved a little bit this stuff, by upgrading to the last version of sprockets, readding the deprecated precompile method, and making it return an asset manifest. I'm loading this manifest when I start the app, so that I don't have to rebuild the file paths with the fingerprint each time. Anyways... I hope I'll be able to move to 3.1 soon ^^.

– Robin Oct 28 at 15:59.

I'm trying to replicate the basics of the asset pipeline introduced in rails 3.1 in my rails 3.0 app. The thing is, I don't want the rails app to serve static assets. The server should do it.

That's why you can precompile assets in rails 3.1, if I understood correctly. So I've made a rake task that does just that (using the precompile method of Sprockets::Environment). And it works, I have all my assets at /public/assets/.

But in rails 3.1, you can do something like that in your style.css.scss. In the precompiled file. Same for stylesheet_link_tag, javascript_link_tag which are overwritten in rails 3.1 to add the hash, if I'm not mistaken.

How can I do this? Give me every idea you can have!

I have used the same gists as a basis, and it works fine. I have made some changes though. Maybe you can try that, see if it helps: https://gist.github.Com/1112393 ps: I guess you solved it yourself since it's been a month... I personally have another problem: How to use Sprockets 2 with Rails 3.0.

X (how to use precompiled assets) If you solved it already, or found another way to make this efficient on production, could you help me? Thanks.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions