未找到链轮文件异常
我正在尝试一些 Rails 的示例应用程序。我创建了一些 控制器和页面。但是当我尝试访问其中一个时,我得到了一个 网页上的异常:
Sprockets::FileNotFound in Pages#home
Showing c:/railscode/test_app/app/views/layouts/application.html.erb
where line #6 raised:
couldn't find file 'jquery'
(in c:/railscode/test_app/app/assets/javascripts/application.js:7)
Extracted source (around line #6):
3: <head>
4: <title>TestApp</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %> 8: </head> 9: <body>
Rails.root:`c:/railscode/test_app`
我使用以下命令创建了一些控制器:
$ rails generate controller Pages home contact
create app/controllers/pages_controller.rb
route get "pages/contact"
route get "pages/home"
invoke erb
create app/views/pages
create app/views/pages/home.html.erb
create app/views/pages/contact.html.erb
invoke rspec
create spec/controllers/pages_controller_spec.rb
create spec/views/pages
create spec/views/pages/home.html.erb_spec.rb
create spec/views/pages/contact.html.erb_spec.rb
invoke helper
create app/helpers/pages_helper.rb
invoke rspec
create spec/helpers/pages_helper_spec.rb
invoke assets
invoke js
create app/assets/javascripts/pages.js
invoke css
create app/assets/stylesheets/pages.css
只是想知道问题可能出在哪里以及在哪里查找?我是 通过 URL 访问页面: http://localhost:3000/pages/home
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
取消注释
application.js 文件中的行并重新启动应用程序对我有用。
Un-commenting the line
in application.js file and restarting the application is what worked for me.
安装 http://metaskills.net/2011/09/26/less-is-more-using-twitter-bootstrap-in-the-rails-3-1-asset-pipeline/
我做了
rake assets:clean asset:precompile
,但这没有帮助。有用的是按照 afaf12 的建议重新启动 Rails 应用程序。Had a similar problem with
FileNotFound
fortwitter/bootstrap
after installing http://metaskills.net/2011/09/26/less-is-more-using-twitter-bootstrap-in-the-rails-3-1-asset-pipeline/I did
rake assets:clean assets:precompile
, but that didn't help. What helped was restarting the rails application as suggested by afaf12.对我来说,解决方案是运行
yarn install
。青年MMVFor me, the solution was to run
yarn install
. YMMV您的
jquery-rails
gem 很可能已经过时了。当我遇到类似的错误时,更新 gem 解决了问题。您是否从头开始将其创建为 Rails 3.1 应用程序?或者您是否从某处下载代码(或更新旧的应用程序)?
It's quite possible that your
jquery-rails
gem is outdated. When I ran into a similar error, updating the gem solved the issue.Did you create this as a Rails 3.1 application from scratch? Or are you downloading code from somewhere (or updating an older app)?
在rails 6.xx中,可以通过执行来解决问题
In rails 6.x.x the problem can be solved by executing
只需向
config/initialize/assets
添加注释,然后重新启动rails 服务器
。Just add a comment to your
config/initialize/assets
and then restart yourrails server
.