Rails / Devise - 如何显示注册信息(不只是编辑它) [英] Rails/Devise - How to show registration information (not just edit it)
问题描述
我今天安装了Devise,到目前为止,一切都很好。似乎没有提供的唯一的事情是注册#显示操作,其显示用户信息(而不是注册编辑页面)。我试图覆盖注册控制器,但是得到错误:对于此控制器上的所有操作,未知操作 - AbstractController :: ActionNotFound。有人知道如何显示个人资料?谢谢!
I installed Devise today and everything works fine so far. The only thing devise seems not to offer is a 'registration#show' action, which displays the user information (instead of the registration edit page). I tried to override the registrations-controller, but get the error: 'Unknown action-AbstractController::ActionNotFound' for all actions on this controller. Does anybody know how to display the profile information? Thanks!
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
super
end
def show
end
def update
super
end
end
推荐答案
我将尝试根据我的身份验证模型创建一个新的控制器,假设我的身份验证模型是User。只需创建一个新的控制器并制作一个显示页面。这样的东西应该可以工作。
I would try to make a new controller based on my authentication model, let's say my authentication model is User. Just create a new controller and make a show page. Something like this should work.
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
# If this show page is only for the currently logged in user change it to @user = current_user
end
end
现在只需添加一个视图,您可以列出所需的属性看到你应该完成:)
Now simply add a view where you list the attributes you want to see and you should be done :)
这篇关于Rails / Devise - 如何显示注册信息(不只是编辑它)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!