1

我是 rails 和 heroku 的新手,希望有人可以帮助我解决我遇到的问题。我有一个雪松堆栈。当我推送它时,我将 config.assets.initialize_on_precompile = false 添加到我的 application.rb 文件中“运行:rake assets:precompile”。但是,我没有看到任何提及我的 jquery-ui-1.8.18custom.css 文件。当我运行 heroku logs 时,它抱怨这个文件没有预编译。我错过了什么吗?当我尝试在本地进行预编译时,它只是挂起,但据我所知,无论如何我都不应该在本地进行,最好不要这样做。

有什么建议么?

这是我对heroku的推动的结束:

   Running: rake assets:precompile
   /usr/local/bin/ruby /tmp/build_3gao4dm3wwned/vendor/bundle/ruby/1.9.1/bin
/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
-----> Rails plugin injection
   Injecting rails_log_stdout
   Injecting rails3_serve_static_assets
-----> Discovering process types
   Procfile declares types      -> (none)
   Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 16.2MB
-----> Launching... done, v82
   http://MYAPPNAME.herokuapp.com deployed to Heroku

这是我的错误日志:

  2012-03-14T15:40:29+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms

2012-03-14T15:40:29+00:00 app[web.1]: Rendered homes/index.html.erb within layou
ts/application (0.4ms)
2012-03-14T15:40:29+00:00 app[web.1]:     2: <html>
2012-03-14T15:40:29+00:00 app[web.1]:
2012-03-14T15:40:29+00:00 app[web.1]: ActionView::Template::Error (jquery-ui-1.8
.18.custom isn't precompiled):

更新:

我将 config.assets.compile = true 添加到 production.rb ,这似乎解决了问题。这有什么问题吗?

作为替代方案,我尝试将其添加到 application.rb 中: onfig.assets.precompile += %w( *.js *.css ) 然后运行 ​​rake precompile ,但我仍然收到错误。

4

1 回答 1

1

这可能是两件事。如果您尝试从视图直接链接到资产,则需要将其设置为预编译:

http://neilmiddleton.com/precompiling-non-default-assets-with-rails-3/

但是,如果它只是在树中并且您希望它包含在其中,application.css那么您需要确保它直接在清单中,或者在包含的树之一中(如果有任何列出)。

例如(application.css):

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require "reset"
 *= require "base"
 *= require "jquery-ui-1.8.18.custom"
*/
于 2012-03-14T18:05:17.920 回答