ruby-on-rails – 添加新的路由操作

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 添加新的路由操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在用户控制器中收到了这些操作 @H_301_2@class UsersController < ApplicationController def index #default action ... end def new #default action ... end def another_new ... end def create ... end def another_create ... end end

我想要能够
/ users / another_new并从某种链接调用:method => :another_create
make / users / another_new

我得到以下config / routes.rb

@H_301_2@get '/users/another_new' :to => 'users#another_new' resources :users

我的问题是如果这是添加get的正确方法以及如何添加another_create方法.

解决方法

在你的config / routes.rb文件中这样做 @H_301_2@resources :users do collection do get 'another_new' post 'another_create' end end

还要看看HERE,以清楚理解概念.

希望这可以帮助你吗?

猜你在找的Ruby相关文章