【问题标题】:Cannot precompile all files (app\assets) in rails application though rake assets:precompile无法通过 rake assets:precompile 在 rails 应用程序中预编译所有文件(app\assets)
【发布时间】:2015-08-25 22:56:26
【问题描述】:

我有一个 Rails 应用程序,现在尝试在 Win2012 上将它运行到我的本地服务器。

https://github.com/carloscoca/loccasions

我尝试通过 rake assets:precompile 命令预编译 app\assets 中的所有文件,但没有出现错误。

但是,我通过 localhost 运行该网站,但看起来不完整,它需要一些文件,我检查了日志文件。 (有些文件是预编译的,有些不是,在manifest文件中是一样的)。

我试过 config.assets.compile = true,没有结果,也有一些配置,没有运气

Started GET "/stylesheets/layout.css" for 127.0.0.1 at 2015-06-07 10:28:45 -0400

ActionController::RoutingError (No route matches [GET] "/stylesheets/layout.css"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)


Started GET "/assets/default.css" for 127.0.0.1 at 2015-06-07 10:28:45 -0400
Served asset /default.css - 404 Not Found (2ms)

ActionController::RoutingError (No route matches [GET] "/assets/default.css"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)


Started GET "/assets/default.js" for 127.0.0.1 at 2015-06-07 10:28:45 -0400
Served asset /default.js - 404 Not Found (0ms)

ActionController::RoutingError (No route matches [GET] "/assets/default.js"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)


Started GET "/stylesheets/skeleton.css" for 127.0.0.1 at 2015-06-07 10:28:45 -0400

ActionController::RoutingError (No route matches [GET] "/stylesheets/skeleton.css"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)


Started GET "/stylesheets/base.css" for 127.0.0.1 at 2015-06-07 10:28:45 -0400

ActionController::RoutingError (No route matches [GET] "/stylesheets/base.css"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)


Started GET "/javascripts/tabs.js" for 127.0.0.1 at 2015-06-07 10:28:45 -0400

ActionController::RoutingError (No route matches [GET] "/javascripts/tabs.js"):


Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)

【问题讨论】:

  • 我通常使用特定的环境进行编译:bundle exec rake assets:precompile RAILS_ENV=production 我不知道为什么,但只使用 rake assets:precompile 我有问题(很久以前)
  • 我假设您尝试在本地主机上运行生产?在您的 config/environnement/production.rb 检查 config.serve_static_files = true (我认为默认情况下为 false,因为您的生产服务器通常会提供静态文件)。
  • rake assets:precompile rake assets:precompile RAILS_ENV=development --trace rake assets:precompile RAILS_ENV=production --trace 我尝试在生产、开发、配置环境中使用 config.serve_static_files = true 命令 rake 工作在 app\assets 中有一些文件,我不知道为什么有些文件而不是全部
  • 在您的 config/application.rb 中,您可能需要在这一行中添加特定文件:config.assets.precompile += %w(base.*, skeleton.* .....)

标签: ruby-on-rails ruby-on-rails-3.1


【解决方案1】:

这对我有用,这个答案属于“编码上瘾”

在您的 config/application.rb 中,您可能需要在这一行中添加特定文件:config.assets.precompile += %w(base., skeleton. ... ..)

【讨论】:

    猜你喜欢
    • 2012-09-02
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    相关资源
    最近更新 更多