在使用devise时,users_path(user)返回/users.id而不是/ users / id [英] users_path(user) returns /users.id instead of /users/id when using devise

查看:107
本文介绍了在使用devise时,users_path(user)返回/users.id而不是/ users / id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现当我使用 users_path(user)它返回 /users.id 其中id是id的用户,但我希望它返回 / users / id 。我的config routes.rb如下所示。

I find that when I use users_path(user) it returns /users.id where id is the id of the user but I want it to return /users/id. My config routes.rb looks like the following.

# config/routes.rb
Test::Application.routes.draw do
  root to: "static_pages#home"
  resources :users, only: [:index, :show]

  devise_for :users
end


推荐答案

将其用于单一用户的路径:

Use this for a path to a singular user:

user_path(user)

使用这个路径给所有用户或索引页面:

Use this for a path to all the users, or the index page:

users_path # no arguments

这篇关于在使用devise时,users_path(user)返回/users.id而不是/ users / id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆