I have a view with the following link generator:
- @tags.each do |tag|
= link_to tag.name, :controller => "images", :action => "#{tag.name}"
@tags
is Tag.all
. It displays the links with the correct names, mouseover shows e.g.
http://localhost:3000/Images/tagname
but if I click on one the error is:
No route matches {:controller=>"", :action=>""}
How can it say :controller
is empty when I specified :controller => "images"
?
rake routes (relevant part):
images GET /images(.:format) images#index
POST /images(.:format) images#create
new_image GET /images/new(.:format) images#new
edit_image GET /images/:id/edit(.:format) images#edit
image GET /images/:id(.:format) images#show
PUT /images/:id(.:format) images#update
DELETE /images/:id(.:format) images#destroy
tags GET /Images(.:format) tags#index
POST /Images(.:format) tags#create
new_tag GET /Images/new(.:format) tags#new
edit_tag GET /Images/:id/edit(.:format) tags#edit
tag GET /Images/:id(.:format) tags#show
PUT /Images/:id(.:format) tags#update
DELETE /Images/:id(.:format) tags#destroy
One tag e.g. is "saturn
", so I added this route too in routes.rb
:
match '/Images/saturn' => 'images#saturn'
which leads to:
Images_saturn /Images/saturn(.:format) images#saturn
I also have a method "saturn
" in my images controller.