How to create a profile after user registration using Rails3 & Devise

I am making a simple user with a profile application. User registers and automatically logged in. While working fine. Now I would like to create a profile after successful registration and redirect the user to his profile.

I have a user model and a controller. The developer also created a registration controller. I set the gem. I copied the project and I plan to override the create action.

First, no matter what I edit in registrations_controller.rb, nothing changes.

class Devise::RegistrationsController < ApplicationController
 prepend_before_filter :require_no_authentication, :only =>
[ :new, :create, :cancel ]
 prepend_before_filter :authenticate_scope!, :only =>
[:edit, :update, :destroy]
 include Devise::Controllers::InternalHelpers

Secondly, how to insert a profile creation step?

def create
   build_resource

   if resource.save
     if resource.active?
       set_flash_message :notice, :signed_up
       sign_in_and_redirect(resource_name, resource)
     else
       set_flash_message :notice, :inactive_signed_up, :reason =>
resource.inactive_message.to_s
       expire_session_data_after_sign_in!
       redirect_to after_inactive_sign_up_path_for(resource)
     end
   else
     clean_up_passwords(resource)
     render_with_scope :new
   end
 end

I thought to add

 current_user.create_profile under is resource.active?

How do you guys solve this problem?

+5
1

<code> . , .

: root_path . , . - root_path .

match '/user/profile/new' => 'profiles#new', :as => 'user_root'

profile#new . profile#new , before_filter profile#new, , - , , , .

, , redirect_path : https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in

+4

All Articles