Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Try using:

<%= javascript_include_tag :defaults  %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top