【问题标题】:Devise/Rails: after_sign_up_path_for(resource)设计/Rails:after_sign_up_path_for(resource)
【发布时间】:2013-05-29 15:25:11
【问题描述】:

我在我的 rails 应用程序中使用 devise 来进行用户注册/登录。注册时,我想将用户重定向到其个人资料页面。

我做了 rake 路由和编辑,root 是:

/profiles/:id/edit

我在注册控制器中写了这个:

def after_sign_up_path_for(resource)
'http://localhost:3000/profiles/#{resource.id}/edit'
end

但它不起作用。有人可以帮忙吗?

【问题讨论】:

    标签: devise ruby-on-rails-3.2


    【解决方案1】:

    你不应该使用:

    def after_sign_up_path_for(resource)
      edit_profile_path(resource)
    end
    

    而不是硬编码http://localhost:3000/profiles/#{resource.id}/edit

    也将有助于发布您的路线文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 2016-08-02
      相关资源
      最近更新 更多