部署后将自定义CSS和Javascript链接到Rails

我有一个Rails应用程序它的css和js链接在本地工作正常,因为我使用:

    

我用Google搜索了所有我发现的Heroku指南 ,我对资产管道事情感到困惑! 我也运行了这个命令:

 bundle exec rake assets:precompile 

它确实在公共目录中创建了一些文件,如指南中所述:

现在在Heroku上一切都很简单,没有设计也没有Css和JS。

当我跑的时候

Heroku Logs

这就是我得到的CSS和JS文件的严重无路由匹配如下:

2013-06-10T10:06:28.184255 + 00:00 app [web.1]:ActionController :: RoutingError(没有路由匹配[GET]“/assetscv.png”):

这只是一行,我为其他文件获得了更多这些,并预先生成了loggs行

任何帮助将不胜感激谢谢!

PS:

我试过了

     

我有一堆错误,在heroku上它说抱歉出了问题

在application.rb(config / application.rb)中

  # Enable the asset pipeline config.assets.enabled = true 

之后在production.rb文件(config / environments / production.rb)中这样做

  # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) #config.serve_static_assets = true # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true 

那么你应该包括你所有的js和css,

  config.assets.precompile += %w(jquery.js jquery_ujs.js PIE.js check_list.js dom-drag.js jquery-1.4.2.min.js jquery-1.7.1.min.js jquery-1.8.3.js jquery-ui.js jquery.accordion.js jquery.corner.js jquery.countdown.js jquery.dimensions.js jquery.masonry.min.js jquery.tinycarousel.min.js jquery.validationEngine-en.js jquery.validationEngine.js questionnaire.js prototype.js users.js) config.assets.precompile += %w(ie7.css ie8.css about_us.css admin_menu.css blog.css default.ultimate.css designer_directory.css designer_directorynew.css drop.css greenstore.css menu.css MenuMatic_dev.css message_view.css product.css setting1.css style1.css styles.css validationEngine.jquery.css) 

在使用此命令进行预编译之后

  $ RAILS_ENV=production bundle exec rake assets:precompile 

然后$ heroku restart

它应该工作。

有关详细信息,请阅读http://guides.rubyonrails.org/asset_pipeline.html