I am trying to create a custom route that indexes reviews
by a scope of shop_id
I have this in my routes.rb:
get '/reviews/:shop_id' => 'reviews#index', :as => :reviews
And this output from my rake routes:
reviews GET /reviews/:shop_id(.:format) reviews#index
And just to be complete, here is my ReviewsController
:
class ReviewsController < BaseController
def index
@shop = Shop.find params[:shop_id]
@reviews = @shop.reviews.all
end
end
When I try to load http://testshop.dev:3000/reviews/2
I get this error:
No route matches [GET] "/reviews/2"
Why? And how do I fix it?