开发者

Rails/Devise - How to show registration information (not just edit it)

开发者 https://www.devze.com 2023-01-22 10:17 出处:网络
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

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 th开发者_Go百科is 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 


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 :)


Infact devise by-itself offers a great way to customize it.

try running :-

 "rails generate devise_views" or in newer version of devise try the below    
 "rails generate devise:views" .

This will generate all the views, which you can edit , customise and set route to.
Try this link http://asciicasts.com/episodes/210-customizing-devise for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号