gpt4 book ai didi

routes - 在Rails 3中路由: Map with options?

转载 作者:行者123 更新时间:2023-12-04 20:24:03 25 4
gpt4 key购买 nike

我似乎找不到在Rails 3中使用选项映射路线的文档。

作为一个具体的例子,我需要翻译

map.with_options :controller => 'users' do |signup|
signup.signup '/signup',
:action => 'landing',
:conditions => { :method => :get }
signup.premium '/signup/premium',
:action => 'new',
:level => 'premium',
:conditions => { :method => :get }
signup.premium '/signup/premium',
:action => 'create',
:level => 'premium',
:conditions => { :method => :post }
signup.free '/signup/free',
:action => 'new',
:level => 'free',
:conditions => { :method => :get }
signup.free '/signup/free',
:action => 'create',
:level => 'free',
:conditions => { :method => :post }
end

转换为rails3的正确语法。我敢肯定,被我忽略的事情一定很简单,但是任何帮助或与文章的链接都将是奇妙的。

最佳答案

scope '/signup' do
match '/signup' => "users#landing", :as => :signup
get '/:level' => 'users#new', :as => :signup_new
post '/:level' => 'users#create', :as => :signup_create
end

这正是我一直在寻找的东西,最初(对我而言)尚不清楚这是选项的转换方式。

关于routes - 在Rails 3中路由: Map with options?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3103765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com