I want to override Devise RegistrationsContollers'create an action so that when a user subscribes, I can associate a model UserProfilewith that user.
So, following the recommendations in the Readme, I redefine the action:
class Users::RegistrationsController < Devise::RegistrationsController
def create
self.user_profiles.build
current_user.user_profiles.build
some other way???
end
end
devise_for :users, :controllers => { :registrations => 'users/registrations' }
Devise creates an entry in a table users, but how do I link UserProfileto this entry?
I tried google search but i just can't get it to work! Any help is greatly appreciated.
(I am now using Devise 1.1.5 on Rails 3.0.3)
SOLVE:
Adding a solution for others:
class Users::RegistrationsController < Devise::RegistrationsController
def create
super
@user.build_user_profile
@user.user_profile.some_data = 'abcd'
@user.save!
end
end
source
share