我是铁杆新手,我试图路线
0.0.0.0:3000/ratings/list
控制器ratings
和方法list
但我会使用index
作为参数
list
方法
我的routes.rb是这样的
resources :ratings
match 'ratings/:won/update/:lost' => 'ratings#update'
match 'ratings/list' => 'ratings#list'
和rake路线是
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
答案 0 :(得分:4)
最好的方法是使用收集路线
resources :ratings do
collection do
get 'list'
end
end
答案 1 :(得分:1)
尝试
match 'ratings/list' => 'ratings#list'
前
resources :ratings
Rails路线先到先得!