动态资产加载heroku
问题描述:
我正在为网站https://looky.co实施网站导览功能,并且我只想在show_site_tour
设置为true时发送site_tour.js
文件。 (show_site_tour
是一个数据库列)。动态资产加载heroku
我有它在我的application.html.haml(版式文件)成立。问题在于heroku运行资产管道的方式。
目录结构
\ app
\ assets
\ javascripts
\ guiders
site_tour.js
基本问题是,当我尝试只包括数据库列等于成立的情况下该文件夹,Heroku的给出了一个“资产不预编译”错误。
在我application.html.haml
%head
= javascript_include_tag 'application'
- if current_user.show_site_tour == true
= javascript_include_tag 'guiders/site_tour'
那么,怎样才能使我与Heroku的流水线工作的呢? 基本上主要的问题是,如何在heroku上有多个javascript文件?
答
基本上,你需要告诉资产管道保持site_tour
文件分开。
config.assets.precompile += %w(guiders/site_tour)
您应该结束了两个JavaScript文件后,此设置便会生效,application.js
和site_tour.js
。
您可以通过使用预编译rake
资产在本地进行测试。
bundle exec rake assets:precompile
这将告诉你输出如何在Heroku上结束。
这可能也是值得注意的是Heroku requires that you have the following setting set to false。
config.assets.initialize_on_precompile = false
你能后的输出'Heroku的logs'? – Kashyap 2013-05-11 04:58:37