Ovesh
Ovesh

Reputation: 5379

How can I disable some of the routes for resources on rails 3?

I'd like to define a model as a resource to get all the REST URLs.

But, I'd like to disable some of the generated routes (e.g., DELETE). Is there an easy API for this, or do I just need to declare all the routes individually?

Upvotes: 1

Views: 754

Answers (3)

sameera207
sameera207

Reputation: 16629

you have two ways of doing this

in config/routes.rb

1) as @emm, suggested define only the routes you want

2) use except keyword to exclude routes

Ex: Excluding destroy action 

resources :books, :except => [:destroy]

read more here

HTH

Upvotes: 2

Shane Andrade
Shane Andrade

Reputation: 2675

You can also exclude specific actions like this: resources :articles, except: :destroy

Upvotes: 0

t56k
t56k

Reputation: 6981

Something like this in routes.rb:

resources :photos, :only => [:index, :show]

See more here.

Upvotes: 2

Related Questions