为什么我会收到“没有路线匹配"的消息?对资产管道的请求? [英] Why do I get "no route matches" for requests to the asset pipeline?

查看:80
本文介绍了为什么我会收到“没有路线匹配"的消息?对资产管道的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力升级应用程序以使用Rails 3.1,并且正在尝试使用资产管道.作为测试,我已将foobar.js添加到app/assets/javascripts.

I'm working on upgrading an app to use Rails 3.1 and I'm trying to use the asset pipeline. As a test, I've added foobar.js to app/assets/javascripts.

application.rb中,我添加了config.assets.enabled = true.继续本指南,我认为这就是我的全部必须做.

In application.rb, I've added config.assets.enabled = true. Going on this guide, I think that's all I have to do.

如果我加载控制台并检查Rails.application.config.assets.paths,则在加载路径中确实看到了app/assets/javascripts.另外,如果我检查MyAppName::Application.assets,则会返回具有相同路径的Sprockets::Environment对象.

If I load the console and check Rails.application.config.assets.paths, I do see app/assets/javascripts in the load path. Also, if I check MyAppName::Application.assets, I get back a Sprockets::Environment object which has the same paths.

对我来说一切都很好.

在视图中,我正在使用javascript_include_tag('foobar').输出以下HTML:<script src="/javascripts/foobar.js" type="text/javascript"></script>

In a view, I'm using javascript_include_tag('foobar'). That outputs the following HTML: <script src="/javascripts/foobar.js" type="text/javascript"></script>

跟随该链接会给我一个错误:No route matches [GET] "/javascripts/foobar.js"

Following that link gets me an error: No route matches [GET] "/javascripts/foobar.js"

我缺少一些设置吗?

我当前正在使用:

  • ruby​​-1.9.2-p290
  • rails-3.1.0.rc6
  • sprockets-2.0.0.beta.14(Rails要求)

推荐答案

我仍然必须手动将文件添加到管道中(请参阅

I still had to add the files manually to the pipeline (see link).

我想这是因为Rails 3.1仍处于测试版

I guess it's because Rails 3.1 is still in beta

这篇关于为什么我会收到“没有路线匹配"的消息?对资产管道的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆