Reputation: 8964
I'm currently defining routes for my pages in the following manner:
get "home/index"
get "photo/index"
get "project/index"
get "home/about"
root :to => 'home#index'
However, I can only seem to be able to create a link to the photo/project index pages by using:
<a href="/photo/index">link</a>
<a href="/project/index">link</a>
In the URL, the "index" part also shows up. I can't simple use /photo
in the a
link, because rails throws a routing error:
No route matches [GET] "/photo"
How would I create a route match for this?
Upvotes: 3
Views: 2887
Reputation: 3376
The best answer is to use match. Don't forget to include via
to preserve your restriction on the http method:
match "/photo", to: "controller#action", :via => 'get'
Upvotes: 3
Reputation: 9190
match "/photo", to: "controller#action"
http://guides.rubyonrails.org/routing.html#connecting-urls-to-code
Upvotes: 5