So, I have an application that uses Rails 3.1.3 and is deployed under Jruby . We allow users to import their own themes (so their own CSS content), and for this reason we do not precompile our assets in production (I know the reasons for the precompilation performance, however we do not find the performance is bad, and it was the best solution for us).
Since we want to support multiple languages, we also have translation files. Rails translations are in config/locales/*.yml , and then we have the translations needed for our Javascript files. We used to put these translations in the assets/javascripts/config.js , but this is very fatal for the future. We need a solution that allows Javascript files to be extracted from config/locales/*.yml . We met the i18n-js gem ( i18n-js ).
This gem works exactly as expected locally. However, in production we get errors. The first problem was application.js could not find the i18n.js file. This made sense to me, since we did not precompile the assets, and i18n-js Gem, obviously, was not installed on the production server, the application would not have access to the i18n.js. So I added the file manually to the assets/javascripts/ path. This fixed this error.
Now we get 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 checked tmp-gems.jar and gems.jar , and the file is actually there ... So it bothers me. My thoughts are that i18n-js Gem simple assumes that you precompile your assets and were not intended to work without it in production where gems are not actually installed on the server. However, I was wondering if anyone could give some advice on this thought. Am I right, or is there a way around this?
Note. If I pre-collect assets - there is no problem in production. And also note that this production problem appeared only when we started using this Gem - so I know that this is due to this use of precious stones, and nothing more. Before this change, everything worked.
In addition, if someone has the best suggestions for solving the language problem (we do not want translations to be supported in the JS file, but in the local YAML file). I would appreciate suggestions on this!
Thanks!