开发者

Rails: How to disallow access to new, delete, edit URL for a resource?

开发者 https://www.devze.com 2023-03-29 04:36 出处:网络
I know Rails generate new, delete, and edit, and whatever the other is for all resources. So if you have a model user, you can go to /user/1, etc. But I want all of these auto-generated urls to be dis

I know Rails generate new, delete, and edit, and whatever the other is for all resources. So if you have a model user, you can go to /user/1, etc. But I want all of these auto-generated urls to be disallowed 开发者_运维百科access? How do I do that?


You can restrict the routes when you say resources :users:

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


Change your config/routes.rb file by removing map.resources :users and just add the route that you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消