刚为我的应用做了一些基本的样式。使用Twitter Bootstrap ....应用程序部署到Heroku并正在工作但现在使用Bootstrap样式更新我收到此错误:
ActionView :: Template :: Error(/app/app/assets/stylesheets/application.css已被要求):
任何人都有任何想法。现在已经忙了几个小时了。尝试过一堆东西。其中一些提到:
Why do I get an ActionView::Template::Error only when trying to upload an App to Heroku?
2013-07-17T15:12:26.494137+00:00 app[web.1]: Started GET "/" for 71.203.124.202 at 2013-07-17 15:12:26 +0000
2013-07-17T15:12:27.403656+00:00 app[web.1]: 4: %title
2013-07-17T15:12:27.403656+00:00 app[web.1]:
2013-07-17T15:12:27.403656+00:00 app[web.1]: ActionView::Template::Error (/app/app/assets/stylesheets/application.css has already been required):
2013-07-17T15:12:27.403656+00:00 app[web.1]: 3: %head
2013-07-17T15:12:27.403656+00:00 app[web.1]: 5: Current Lines and Analysis
2013-07-17T15:12:27.403656+00:00 app[web.1]: 6: = stylesheet_link_tag "application", :media => "all"
2013-07-17T15:12:27.403656+00:00 app[web.1]: 7: = javascript_include_tag "application"
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/navigation/_main_nav.html.haml (1.4ms)
2013-07-17T15:12:27.403656+00:00 app[web.1]: app/views/layouts/posts.html.haml:6:in `_app_views_layouts_posts_html_haml___3387163029388442478_46287060'
2013-07-17T15:12:27.403656+00:00 app[web.1]: 8: = csrf_meta_tags
2013-07-17T15:12:27.403656+00:00 app[web.1]: 9: :javascript
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_events_sort_toggle.html.haml (1.0ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_main_flash.html.haml (0.1ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_header.html.haml (4.5ms)
2013-07-17T15:12:27.403892+00:00 app[web.1]:
2013-07-17T15:12:27.403892+00:00 app[web.1]:
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_events_sidebar.html.haml (22.6ms)
2013-07-17T15:12:27.404248+00:00 app[web.1]: Completed 500 Internal Server Error in 904ms
2013-07-17T15:12:27.404086+00:00 app[web.1]: Processing by PostsController#index as HTML
2013-07-17T15:12:27.404248+00:00 app[web.1]: Rendered posts/index.html.haml within layouts/posts (40.5ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_posts_sort_toggle.html.haml (1.5ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_posts_multi.html.haml (2.2ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_hot-events-box.html.haml (2.0ms)
2013-07-17T15:12:27.404086+00:00 app[web.1]: Rendered shared/_leagues_toggle.html.haml (2.6ms)
2013-07-17T15:12:27.404248+00:00 app[web.1]: Rendered shared/_top_users_sidebar.html.haml (1.7ms)
2013-07-17T15:12:27.404215+00:00 heroku[router]: at=info method=GET path=/ host=www.webxxxxx.com fwd="xx.203.124.xxx" dyno=web.1 connect=1ms service=918ms status=500 bytes=643
application.css.scss文件
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* 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 bootstrap
*= require_tree .
*/
@import "bootstrap";
当我从帖子布局中取出这两行时,网站呈现但没有样式......
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
有什么想法吗?
答案 0 :(得分:3)
检查application.css
目录中是否有app/assets/stylesheets
个文件。默认情况下,rails
会将application.css.scss
中的内容放在application.css
中。您可能已创建此文件但错过了删除默认application.css
。
答案 1 :(得分:2)
也许与你的问题有关,但是如果你使用源代码控制并且你在过去完成了合并,那么你将拥有一个类似于application.css.orig的样式表,它将包含在require_tree中。我有同样的错误,通过删除* .orig文件,它立即解决了。
基本上,任何名为* .css。*的东西都可能对Rails造成严重破坏。
答案 2 :(得分:0)
我发现删除require_tree。单独添加文件就可以了。也许我有冲突因为我使用rails_admin ???
为遇到此问题的其他人提供此服务。
答案 3 :(得分:0)
我遇到了同样的问题,我通过运行" rake资产来修复它:预编译RAILS_ENV =生产"在当地,然后推回到heroku。