views:

588

answers:

4

When I call the index action of my assets controller, the corresponding index template uses the assets layout which includes this line:

<%= javascript_include_tag 'prototype'  %>

The error I get is:

No route matches "/javascripts/prototype.js" with {:method=>:get}

This is my routes file:

ActionController::Routing::Routes.draw do |map|
  map.resources :assets
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

Any idea what I could be missing here?

Is there a way to explicity define a route for this file?

A: 

You shouldn't need to define a route for this - it should be handled by the rewrite rules in your .htaccess file.

You need to check that your mod_rewrite is enabled, and that the .htaccess file is correct - it should be sending the request to your dispatch.rb only if the requested file does not exist in your public directory. You may also need to check that the file exists.

Mr. Matt
Yes, the file exists so I think your technical explanation is more along the lines of what's going on. Thanks for that info. I'll go and poke around a bit.
pepe
It's highly unlikely that mod_rewrite is involved, this is a Rails app. Nearly all Rails setups completely bypass any of this stuff.
Jim Puls
@Jim Puls: Yeah, that's right, and to do that, they use mod_rewrite.
Mr. Matt
A: 

You don't need to define a route for this file, you need this file. We you create a new project, Rails stores Prototype library in your javascripts folder.

  create  public/javascripts/prototype.js
  create  public/javascripts/effects.js
  create  public/javascripts/dragdrop.js
  create  public/javascripts/controls.js
  create  public/javascripts/application.js

Make sure the file exists. If not, create a new project and copy the files from its /public/javascript folder.

Simone Carletti
It definitely exists.
pepe
A: 

This might also happen if you have a controller called javascripts.

Vagmi Mudumbai
A: 

Try Using

<%= javascript_include_tag :defaults %>

I just saw this on another list - but it didn't help me