Why do I get “no route matches” for requests to the asset pipeline?

南楼画角 提交于 2019-12-11 10:35:20

问题


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.

The Setup

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

Checking it out

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.

That all looks good to me.

Trying to use it

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

The error

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

Is there a piece of setup I'm missing?


Misc Details

I'm currently using:

  • ruby-1.9.2-p290
  • rails-3.1.0.rc6
  • sprockets-2.0.0.beta.14 (required by Rails)

回答1:


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

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



来源:https://stackoverflow.com/questions/7191339/why-do-i-get-no-route-matches-for-requests-to-the-asset-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!