Rails 3 匹配路线助手
Rails 3 helper for match route
在rails 3 应用程序下面的匹配路由定义在routes.rb
match 'accounts/:account_type/:account_id/edit_account' => 'accounts#edit_account'
在控制器中我重定向到这个 URL
redirect_to "/accounts/account/#{account_id.to_s}/edit_account"
它工作正常,但我需要一个路由助手而不是手动构建 URL 像这样的东西
edit_account_accounts_path(account_id: id, account_type: 'some_type')
有什么办法吗?
你可以试试
match 'accounts/:account_type/:account_id/edit_account', to: 'accounts#edit_account', as: 'edit_account_accounts'
如需更多帮助,请参阅 The Lowdown on Routes in Rails 3
在rails 3 应用程序下面的匹配路由定义在routes.rb
match 'accounts/:account_type/:account_id/edit_account' => 'accounts#edit_account'
在控制器中我重定向到这个 URL
redirect_to "/accounts/account/#{account_id.to_s}/edit_account"
它工作正常,但我需要一个路由助手而不是手动构建 URL 像这样的东西
edit_account_accounts_path(account_id: id, account_type: 'some_type')
有什么办法吗?
你可以试试
match 'accounts/:account_type/:account_id/edit_account', to: 'accounts#edit_account', as: 'edit_account_accounts'
如需更多帮助,请参阅 The Lowdown on Routes in Rails 3