问题描述
在我的本地机器上,当我查看我的Rails应用程序时,我的样式表已成功链接到 / assets / stylesheets /
,但是在Heroku中,它更改为 / stylesheets /
大概在 public
目录中,并且不起作用!如何让我的样式表在编译时移动到 public / stylesheets
?
编辑:
$ b $ rake assets:precompile
app
资产
样式表
application.css
application.min.css
home.css
主页.css.scss
home.min.css
scaffolds.css
scaffolds.css.scss
scaffolds.min.css
startups.css
初创公司.css.scss
public
assets
application-3701cb84bbc3c20d5a7ec1aac608fbdb.js
application-3701cb84bbc3c20d5a7ec1aac608fbdb.js.gz
application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css
application-f7ff7ad51f3528ccca1b5c7f2d5b5915 .css.gz
manifest-ad3babc6c84cc0b38f1a98eb594b8235.json
rails-afd7b40a0142ed24738b640e78388de4.png
这是我在 application.html.haml
:
stylesheet_link_tagflat-ui,home.min,media:all
code>
gem flatui-rails
位于我的Gemfile中, * = require flat-ui
在我的 application.css
文件中。
编辑2:
清除了我的 public / assets
文件夹,添加了 public / assets / *
到我的 .gitignore
并推送到我的Heroku回购。在slug编译期间,Heroku运行了资产管道,并创建了 /assets/application-b2c82b0573602f3a368a26f36b99542b.css
,它也链接到我的网站的源代码中,但样式不加载我得到您正在查找的页面不存在。
当我尝试导航到样式表时...现在是什么?
这是我的 application.html.haml
:
! 5
%html
%head
%title StartupCrawler
= stylesheet_link_tagapplication,media:all
= csrf_meta_tags
= yield
rake资产:预编译
这将在公共预编译中文件夹,以便他们可以送达Heroku。
另外,请确保config / environments / production.rb中存在以下行:
config.serve_static_assets = true
然后当然
git push heroku master
On my local machine, when I view my Rails App, my stylesheets are successfully linked at /assets/stylesheets/
but on Heroku, it is changed to /stylesheets/
presumably in the public
directory and does not work! How do I get my stylesheets to move to public/stylesheets
on compilation?
EDIT:
File directory after rake assets:precompile
app
assets
stylesheets
application.css
application.min.css
home.css
home.css.scss
home.min.css
scaffolds.css
scaffolds.css.scss
scaffolds.min.css
startups.css
startups.css.scss
public
assets
application-3701cb84bbc3c20d5a7ec1aac608fbdb.js
application-3701cb84bbc3c20d5a7ec1aac608fbdb.js.gz
application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css
application-f7ff7ad51f3528ccca1b5c7f2d5b5915.css.gz
manifest-ad3babc6c84cc0b38f1a98eb594b8235.json
rails-afd7b40a0142ed24738b640e78388de4.png
Here is my stylesheet link in application.html.haml
:
stylesheet_link_tag "flat-ui", "home.min", media: "all"
gem flatui-rails
is in my Gemfile and *= require flat-ui
is in my application.css
file.
EDIT 2:
Cleared my public/assets
folder, added public/assets/*
to my .gitignore
and pushed to my Heroku repo. During slug compilation Heroku ran the asset pipline and made /assets/application-b2c82b0573602f3a368a26f36b99542b.css
which is also linked in the source code of my site, but the styles don't load and I get The page you were looking for doesn't exist.
when I try to navigate to the style sheet... Now what?
Here's my application.html.haml
:
!!! 5
%html
%head
%title StartupCrawler
= stylesheet_link_tag "application", media: "all"
= csrf_meta_tags
= yield
Michael, I before you push to heroku try:
rake assets:precompile
This will precompile them in the public folder so that they can be served to Heroku. Let me know if that didn't work.
Also, make sure the following line exists in config/environments/production.rb
config.serve_static_assets = true
Then of course
git push heroku master
这篇关于Rails样式表在Heroku上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!