documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Assets are successfully created but not being used when loading the webpages #56

Closed chadwtaylor closed 14 years ago

chadwtaylor commented 14 years ago

I have everything set up for Jammit and it is working (in the sense where the <%= include_javascripts :x %> and <%= include_stylesheets :x %> are being called successfully). The assets.yml has the "package_assets: always" so it could work in both development and production environments.

The page loads successfully with javascript and stylesheets loaded as defined by assets.yml; however, the files in /public/assets/* (as a result of running "jammit -f" from the command line) isn't being used when I check the source code.

I have followed the instructions to the T but I must be missing something else. Has anybody experienced the same where everything is set up but the assets aren't simply being used in development or production environments?

Here is my environment/setup:

I apologize in advance if I missed something here and any pointers as to what my potential overlook might be would be greatly appreciated.

jashkenas commented 14 years ago

I'm a bit confused -- what precisely do you mean by "the assets aren't simply being used"?

If you gist the relevant portions of your assets.yml here, and the helper calls you're using in your templates, and the script tags that the helpers are generating, I'm sure we can get this straightened out shortly.

chadwtaylor commented 14 years ago

Thanks for replying, jashkenas. The JS and CSS files listed in assets.yml are loaded individually as if "package_assets: off". When "package_assets: always", I would expect it to use the bundled JS and CSS asset files.

Here is my assets.yml file:

package_assets: always # (on, off, always) embed_assets: on # (on, off, datauri) compress_assets: on # (on, off) gzip_assets: on # (on, off) package_path: assets # (default to assets) javascript_compressor: yui # (yui, closure)

javascripts: default:

stylesheets: default:

jashkenas commented 14 years ago

It's working fine for me with the package_assets: always line you have in your assets.yml. Are you sure there's not something else screwy going on? Check if the page you're loading has been cached statically with the expanded assets, or if there's a typo in in your template. Another thing to check is to open up a script/console production on your production box, and check the value of Jammit.package_assets. Is it true?

chadwtaylor commented 14 years ago

I ran the script/console as requested and it returned false. I guess that's where I am having problems. Where in the configuration should I force it to true?

chadwtaylor commented 14 years ago

In addition to running "script/console production" as recommended and I was able to run Jammit settings and all values are reading in as configured in assets.yml and for some odd reasons, the Jammit.package_assets is returning "false" although it's set to "always". I even tried "on" and it is still returning false. What am I doing wrong?

Here's the partial output of my assets.yml:

package_assets: always # (on, off, always) package_path: assets # (default to assets) javascript_compressor: yui # (yui, closure) embed_assets: on # (on, off, datauri) compress_assets: on # (on, off) gzip_assets: on # (on, off)

Here's the irb readout:

$ script/console production Loading production environment (Rails 2.3.5)

Jammit.package_assets => false Jammit.package_path => "assets\t\t# (default to assets)" Jammit.javascript_compressor => :yui Jammit.embed_assets => true

chadwtaylor commented 14 years ago

The funny thing just happened -- sometimes just talking here helps and I was able to fix it. Turns out assets.yml doesn't like the commented out parts (ie: # (on, off, always)). I cleared out all comments and now everything is working as expected.

I hope someone who had the same issue (by having comments in their assets.yml file) will appreciate this solution.

Or... someone can make sure Jammit is able to ignore the comments in assets.yml and not break.

Thanks much and many thanks for making Jammit available!

Chad

jashkenas commented 14 years ago

Ah, the good old rubber duck method of debugging....

I've pushed a patch that removes the commented bits from assets.example.yml, in hopes that it won't lead any other folks astray. Thanks for sticking it through and reporting the fix -- I appreciate it.

http://github.com/documentcloud/jammit/commit/95fa94d3c19256018523c0422a6e89b75aec96c0

Closing the ticket.