Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
登录后,我希望将用户定向到
example.com/me
并不是
example.com/users/$ID_NUMBER
我已将以下内容添加到我的 routes.rb
匹配 '/me',到:'users#show'
和 users_controller
@user = current_user redirect_to me_url
但是,我得到重定向循环。我可以毫无问题地调用 example.com/me,但在登录步骤中我不能直接去那里。
您需要在您的routes.rb
routes.rb
match '/me' => 'users#show', :as => :me
该:as => :me部分是创建me_url和me_path帮助者的原因。
:as => :me
me_url
me_path
导轨路由