leshill / handlebars_assets

Use handlebars.js templates with the Rails asset pipeline.
MIT License
648 stars 159 forks source link

Handlebars Version problem #53

Closed zachdixon closed 11 years ago

zachdixon commented 11 years ago

I'm getting a new error:

Uncaught Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version (>= 1.0.0-rc.3) or downgrade your runtime to an older version (<= 1.0.rc.2).

I tried changing the version to <= 1.0.rc.2 which got rid of the error but returned an empty string.

Any help would be appreciated, thanks.

leshill commented 11 years ago

Hi @zachdixon,

You did not mention how you are compiling or serving the assets. All the templates should be recompiled. Did you clear the assets and rebuild? Also check to see if you have assets in public/assets.

zachdixon commented 11 years ago

I'm using the handlebars_assets gem, required handlebars.runtime (tried both), and the changes I made to try the different versions were in my local gem files. My templates are in app/assets/javascripts/templates. Everything was working a couple days ago (Tuesday I believe).

Sorry I'm fairly new to rails and the asset pipeline. How would I recompile the templates?

leshill commented 11 years ago

Hi @zachdixon,

No worries.

By default, in dev mode, assets are compiled on the fly when necessary. When changing the gem, none of the files are changed, so nothing is recompiled automatically. Use:

rake tmp:clear

To force everything to be deleted and recompiled on the next request. (You should not have to restart the server, still folks occasionally report that it was needed.)

Or you might be doing this to compile the assets manually and all at once (similar to production):

rake assets:precompile

Rerunning the command should clear it up. Hope this helps.

zachdixon commented 11 years ago

Perfect, that worked. Also, I was getting that empty string returned from the template due to a structure error in the object I was passing.

Thanks for your help!

sergelerator commented 11 years ago

I'm having this same issue since I updated the gem. Tried the rake tmp:clear command but it didn't work out. I'm having this issue in development mode (haven't tried production yet) so I didn't precompile assets, I believe I should not do it in the dev environment.

sergelerator commented 11 years ago

Nevermind, a server restart was in fact needed :P

eniolopes commented 11 years ago

I'm having this issue on a heroku staging server, in development mode I was able to get it to work following the steps described, the behavior in staging is a little weird, it is compiling some templates just fine, but a few are raising this error. Do you have any clue?

Thanks

EDIT: I updated from handlebars_assets 0.8.1 to 0.12.0

leshill commented 11 years ago

Hi @eniolopes,

Not sure, but you might check that your public/assets directory is empty before deploying to heroku?

eniolopes commented 11 years ago

yep no assets there :(

leshill commented 11 years ago

Hi @eniolopes,

You can force a recompile of all template assets by changing all the template files.

And if you are using a CDN you need to make sure to flush the assets there as well (should happen automatically).

shatle commented 11 years ago

rake tmp:clear :+1:

ghost commented 10 years ago

rake tmp:clear fixed it for me

maxwell commented 10 years ago

If you are on production, and using something like asset_sync

you can change your asset versions by adding this to your production.rb file

config.assets.version = '2.0'

That should expire all of your assets, and recompile your templates with the new handlebars version.