Reputation: 8991
Im new to rails, Im trying to route
0.0.0.0:3000/ratings/list
to the controller ratings
and the method list
but instead I get directed the index
method with list
as the parameter
my routes.rb is like so
resources :ratings
match 'ratings/:won/update/:lost' => 'ratings#update'
match 'ratings/list' => 'ratings#list'
and rake routes is
ratings GET /ratings(.:format) ratings#index
POST /ratings(.:format) ratings#create
new_rating GET /ratings/new(.:format) ratings#new
edit_rating GET /ratings/:id/edit(.:format) ratings#edit
rating GET /ratings/:id(.:format) ratings#show
PUT /ratings/:id(.:format) ratings#update
DELETE /ratings/:id(.:format) ratings#destroy
/ratings/:won/update/:lost(.:format) ratings#update
ratings_list /ratings/list(.:format) ratings#list
Upvotes: 1
Views: 1568
Reputation: 781
The best way is to use collection route
resources :ratings do
collection do
get 'list'
end
end
Upvotes: 4
Reputation: 5767
Try with
match 'ratings/list' => 'ratings#list'
before
resources :ratings
Rails routes are first come, first served!
Upvotes: 1