Reputation: 763
I'm trying to access:
http://localhost:3000/images/Header.png
but I keep getting this error:
Routing Error
No route matches "/images/Header.png" with {:method=>:get}
And here are my routes:
ActionController::Routing::Routes.draw do |map|
map.resources :worker_antpile_statuses
map.resources :worker_antpiles
map.resources :antcolonies
map.resources :antpiles
map.resources :clients
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
Upvotes: 8
Views: 10910
Reputation: 5803
Static assets need to go in the /public folder or else you'll get the routing error. For a static image at http://localhost:3000/images/Header.png
you want to place Header.png in RAILS_ROOT/public/images
When given any url, Rails will check for a file existing at the path from RAILS_ROOT/public directory before attempting to match any routes.
For example when a Rails server receives a request for http://localhost:3000/users/1
it will attempt to send the contents of RAILS_ROOT/public/users/1
. If no file exists, the route matching routine kicks in.
Upvotes: 17
Reputation: 78003
The last two lines of your routes.rb
are catch-all routes that will match any previously unmatched URLs.
Comment out those two lines and it will work, which is what you want to do when you use RESTful routing in all your application.
See this excellent guide for all you need to know about Rails routes.
Upvotes: 1