Leahcim
Leahcim

Reputation: 42049

constraining a route in Rails

I have a controller named results_controller. It uses

resources :results

in the router.

One problem is that I don't want people to be able to see the results page by typing in the following

www.example.com/results

Is there a way to put a redirect on that www.example.com/results without interfering with any of the other resources :results?

Upvotes: 0

Views: 46

Answers (1)

deviousdodo
deviousdodo

Reputation: 9172

The simplest way would be to not generate that specific route:

resources :results, :except => :index
// or you can use
resources :results, :only => [:show, :destroy]

Here's a good intro to rails routing: http://guides.rubyonrails.org/routing.html

Upvotes: 2

Related Questions