I want to put some user preferences in my JavaScript. Previously I’ve done it by rendering my JavaSript file preferences.js.erb by controller via <%= javascript_link_tag …>. How it should be cooked now with 3.1 Assets pipeline ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In no way.. application.js is static – on production it is generated into one big static file by
rake assets:precompilecommand.So you can include separate file preferences.js.erb as you proposed or render preferences directly on page – second is better because you save 1 request (but worse because they won`t be cached).
To minimize size of preferences it would be better to present them in JSON, like this: