I've setup a simple app and added a scaffold to do some of the work for me (I'm a noob).
resources :cars
How do I remove certain actions from the routes? And remove the corresponding urls?
For example I want to keep the 'show' and 'edit' actions & urls.
But I don't want there to be a 'new' 'index' or 'delete'
I understand this is probably a really simple question, but I've not been able to find an answer.
Rails routing is a two-way piece of machinery – rather as if you could turn trees into paper, and then turn paper back into trees. Specifically, it both connects incoming HTTP requests to the code in your application's controllers, and helps you generate URLs without having to hard-code them as strings.
Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.
In Rails, there are seven standard CRUD actions: index, show, new, create, edit, update, and destroy, which relate to specific HTTP verbs and are usually implemented using specific ActiveRecord methods.
Any object that you want users to be able to access via URI and perform CRUD (or some subset thereof) operations on can be thought of as a resource. In the Rails sense, it is generally a database table which is represented by a model, and acted on through a controller.
resources :cars, :except => [:new, :index, :delete]
or
resources :cars, :only => [:show, :edit]
Also take a look at Rails Guides
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With