【发布时间】:2015-07-09 01:58:53
【问题描述】:
我是 Rails 新手,我创建了一个应用,其中用户有一个配置文件,并且可以使用编辑配置文件选项进行编辑。
在我拥有的控制器中,
ProfilesController
在我拥有的视图中,
index.html.erb
edit.html.erb
对于索引页面一切正常,但对于编辑页面,第一次加载很酷,然后刷新后,css文件没有加载。
网址看起来像http://localhost:3000/profiles/25/edit
无论刷新多少次,索引页一切正常,但编辑页令人失望。我检查了浏览器中的元素,上面写着GET http://localhost:3000/profiles/25/assets/bootstrap.min.css [HTTP/1.1 404 Not Found 650ms]
即它在localhost:3000/profiles/25/assets/ 中搜索不存在的文件,而不是在localhost:3000/assets/ 中搜索
编辑:
结构:
app/assets/stylesheets
application.css
bootstrap.min.css
style.css
在 application.html.erb 中,我将 application.css 链接为,
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
和其他css文件一样
<link href="assets/style.css" rel="stylesheet">
<link href="assets/bootstrap.min.css" rel="stylesheet">
我的结构和链接是否正确?如果不是,那么在哪里放置和使用外部 css 文件。
请帮忙!!提前致谢。
【问题讨论】:
-
你是如何加载引导程序的?
-
我觉得assets的路径很奇怪
profiles/25/assets/bootstrap.css,你能给我们看看代码吗? -
@narush 你能发布你的项目/应用程序结构吗?
-
@infused in application.html 。它在第一次加载时工作正常,但在刷新编辑页面时不加载
-
@anonymousxxx 是浏览器发出的 GET 请求,我在检查元素后发现,应该是 /assets/bootstrap.css。
标签: html css ruby-on-rails refresh page-refresh