Reputation: 4575
i have this controller:
gods_controller.rb
class GodsController < ApplicationController
def notifications
@reviews= Review.where("flag = ?", true)
respond_to do |format|
format.html # index.html.erb
end
end
end
routes.rb
resources :gods, :only => [:index] do
get :notifications
end
That route gives me this: http://example.com/gods/1/notifications
but what I want is this: http://example.com/gods/notifications
Thanks in advance!
Upvotes: 0
Views: 39
Reputation: 2143
One thing you could do is, change your current route to this:
match "/gods/:id/notifications" => "gods#notifications"
Upvotes: 0
Reputation: 3282
Try:
resources :gods, :only => [:index] do
collection do
get :notifications
end
end
You can read more details about this here: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions
Upvotes: 2