0
我有一个愚蠢的问题:我有一个JavaScript文件,它具有一些JavaScript常量(用于所有JavaScript代码),这些常量是从rails中“提取”的。预编译js.erb文件或在没有预编译的情况下加载
代码很简单:
var CrossJavascriptSettings = {
desktop_columns: <%= Rails.configuration.extjs_desktop[:icon_columns] %>,
recaptcha_public_key: '<%= Recaptcha.configuration.public_key %>',
tasks_icon_image: '<%= image_path('icons/Clock.png') %>',
no_image: '<%= image_path('icons/Delete.png') %>',
loading_image: '<%= image_path('ext-icons/loading.gif') %>',
loading_image_preloaded: new Image().src = '<%= image_path('ext-icons/loading.gif') %>',
no_image_preloaded: new Image().src = '<%= image_path('icons/Delete.png') %>',
tasks_icon_image_preloaded: new Image().src = '<%= image_path('icons/Clock.png') %>',
available_roles: <%= Rails.configuration.available_roles.each_with_index.collect { |element, index| [index, element] }.as_json %>,
organizations_logo_path: '/assets/organizations/logos/'
};
的问题是,我的文件不会被预编译,这是很奇怪的,因为里面的文件,我使用的东西,只是配置选项,无数据库或类似的。
所以我的问题是,我该如何解决这个问题?有没有办法强制编译该文件与所需的常量,或有任何方式来加载它没有被编译?
运行'rake assets:precompile'预编译我的js.erb到应用程序-... js –
您使用rails 4吗?这可能是不同之处。 –