铁轨中的路线-设置资源时删除操作 [英] routes in rails - removing actions when setting up a resource

查看:80
本文介绍了铁轨中的路线-设置资源时删除操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了一个简单的应用程序,并添加了一个脚手架来为我做一些工作(我是菜鸟)。

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.

推荐答案

resources :cars, :except => [:new, :index, :delete]

resources :cars, :only => [:show, :edit]

也可以看看铁路指南

这篇关于铁轨中的路线-设置资源时删除操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆