I am working on a rails application and I dont need certain routes. for example the user will not be able to create a new “Product”. In fact nobody will since those products are read from a file only. so how can I remove the ‘products/new’ route? should I replace the code in the products controller? Thanks!
Share
You probably shouldn’t have
new,createor other record-altering methods in the ProductsController, since they’re not going to get used, but the actual way to specify which routes exist is in theconfig/routes.rbfile. Typically, you’d have a line in there something like:This provides the basic RESTful routes for products. You can, however, specify that only some of the routes should exist:
Or: