Answer the question
In order to leave comments, you need to log in
How to make a user profile + gem devise?
I want to bind to the User model (this is the essence of the devise gem) user profile.
I do the following:
1) rails generate devise User
Default setting + migration, everything is over.
2) rails g scaffold profile name:string role:string user:references
3) After generation I add has_one :profiles to the User model
In the rails console, in the database itself, I can't find the binding by id
Where did I go wrong?
Advise the decision, I need that after an input each user had the own profile.
Answer the question
In order to leave comments, you need to log in
model/user.rb
In the Devise controller:
class DeviseOverride::RegistrationsController < Devise::RegistrationsController
def create
super
if resource.save
resource.create_profile
end
end
has_one :profiles
I translate:
it has one profile and
And how is the Profile model connected to the User then?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question