How can I get rails to process and serve application.js.erb instead of application.js?
I want to mix Ruby and Javascript code in the file. I am building Javascript arrays from data that i keep in a Rails model and the arrays are static.
How can I get rails to process and serve application.js.erb instead of application.js?
I want to mix Ruby and Javascript code in the file. I am building Javascript arrays from data that i keep in a Rails model and the arrays are static.
Create application.js.erb and put it in views/js/
then you
render :partial => ‘js/application.js.erb’, :locals => {:data => @your_data}
and use variable ‘data’ in your partial like