So I have an application which is using Rails 3.1.3
, and gets deployed under Jruby
. We allow the users to import their own themes (so their own CSS content) and for that reason we do not pre-compile our assets in production (I am aware of performance reasons of pre-compiling, however we don't find the performance hit that bad, and this was the best decision for us).
Since we want to support multiple languages, we also have translation files. Rails translations being in config/locales/*.yml
and then we have translations required for our Javascript files. Previously we were putting these translations in a assets/javascripts/config.js
file - but this is highly unscalable for the future. We wanted a solution that would allow the Javascript files to pull from the config/locales/*.yml
files. We came across the i18n-js
Gem ( i18n-js ).
This gem works exactly as expected locally. However, in production, we are getting errors. The first problem was application.js
could not locate the i18n.js
file. To me, this made sense, since we were not pre-compiling the assets, and the i18n-js Gem would obviously not be installed on the production server, the application would not have access to the i18n.js file. So I added the file manually in the assets/javascripts/
path. That fixed that error.
Now we are getting this error:
2012-10-05[INFO] - Internal Server Error: Sprockets::FileNotFound couldn't find file 'file:/tmp/Jetty_0_0_0_0_application.war____.r5dru7/webapp/WEB-INF/lib/tmp-gems.jar!/gems/activesupport-3.1.3/lib/active_support/locale/en.yml'
(in /tmp/Jetty_0_0_0_0_application.war____.r5dru7/webapp/WEB-INF/app/assets/javascripts/i18n/translations.js)
I have checked the tmp-gems.jar
and the gems.jar
and the file is actually there... So that confuses me. My thoughts are that the i18n-js Gem simple assumes that you are pre-compiling your assets and was not designed to function without that in production where the gems are not actually installed on the server. However, I was wondering if anyone could provide some guidance on that thought? Am I right, or is there a way around this?
Note: If I do pre-compile the assets - there are no issues in production. And also note, this production issue has only shown up when we started using this Gem - so I know it is related to that gem's usage, and nothing else. Everything was working before this change.
Also, if anyone has better suggestions for getting around the language problem (we don't want translations maintained in a JS file, AND in a locales YAML file). I would appreciate suggestions to that end as well!
Thanks!