【问题标题】:How to redirect user to edit page after creation?创建后如何将用户重定向到编辑页面?
【发布时间】:2012-09-08 13:23:55
【问题描述】:

我有点困惑 - 当用户创建成功时。

我可以打电话(工作)

if @wibiya_user.save
 render :edit
end

但是为什么我写的时候

   if @wibiya_user.save
       format.html { redirect_to edit_wibiya_user_path(@wibiya_user) }
   end

我收到路由错误:

No route matches {:action=>"edit", :controller=>"wibiya_users"}

但是我的路线中确实有:

     resources :wibiya_users
 ...
rake routes
  edit_wibiya_user GET    /wibiya_users/:id/edit(.:format) wibiya_users#edit

为什么会这样?

【问题讨论】:

  • 不应该 - 您能否向我们展示您从重定向的位置执行的完整操作,以及与 :wibiya_users 资源相关的所有路由?

标签: ruby-on-rails routing


【解决方案1】:

将您的用户控制器(文件名、类名、重定向等)更改为 WibiyaUsersController。

说明:routes.rb 文件中的resources :wilibya_user 设置了该资源的各种路由。它假设控制器被称为wibiya_users_controller

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2010-09-07
  • 2018-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多