开发者

How do you have the create Action route to an alternative model name?

开发者 https://www.devze.com 2023-02-04 10:48 出处:网络
Routes.rb resources :recovers match \':开发者_StackOverflowcheckedin\' => \'recovers#index\' match \':checkin/:id\' => \'recovers#show\'

Routes.rb

resources :recovers match ':开发者_StackOverflowcheckedin' => 'recovers#index' match ':checkin/:id' => 'recovers#show'

When a new record is created Rails routes the user to /recovers, I would like the user to be routed to /checkedin how do I do this?


You could do the following:

routes.db:

resources :recovers
match 'checkedin' => 'recovers#index', :as => 'checkedin'
match 'checkin/:id' => 'recovers#show'

recovers_controller.rb: in the create method:

redirect_to checkedin_path
0

精彩评论

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