Output (non digest named file) has different content than produced with default rails.
Closed this issue · 1 comments
Hey I guess I found a bug, on turbo-sprockets-rails3 output working differently on what default rails 3 does.
I created a very simple rails app with the following css files in it:
app/
assets/
stylesheets/
home.css # example content "#home { display: inline }"
home/
index.css # example content "#index { display: inline }"
When using the latest turbo-sprockets-rails3, the file placed under public/assets/home.css
has the wrong content (that from the home/index.css):
$ rm -rf public/assets && rake assets:precompile
$ cat public/assets/home.css
#index { display: inline }
However when I remove turbo-sprockets from the Gemfile, that is, using the default
rails 3 asset compilation pipeline, I get the exact content I was expecting:
$ rm -rf public/assets && rake assets:precompile
$ cat public/assets/home.css
#home { display: inline }
I guess it's a bug on turbo-sprockets-rails3 as using it shouldnt affect the way assets get copied/compiled to public/assets with default rails. IMHO turbo-sprockets should only aid on doing it faster, at least that's why I added it to my Gemfile.
I tracked the error down to line:
https://github.com/ndbroadbent/turbo-sprockets-rails3/blob/master/lib/sprockets/static_non_digest_generator.rb#L31
from commit:
dfd9421
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
logical_path.sub!(/\/index\./, '.')
end
I however do not understand why you'd remove the "index." part from the filename, files should be processed and reflect the source they are compiled from, just like default rails does, without causing this unexpected behaviour i'm reporting. Same happens with javascript files.
Any ideas on why was that line added?
Oh, never mind, it was my miss-understanding about how index files work on the assets pipeline.
Here's the link for reference:
http://guides.rubyonrails.org/asset_pipeline.html#using-index-files