A
A
anasasiakiri4enko2016-06-30 16:54:11
Ruby on Rails
anasasiakiri4enko, 2016-06-30 16:54:11

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

2 answer(s)
D
Dmitry Amelchenko, 2016-07-06
@anasasiakiri4enko

model/user.rb
In the Devise controller:

class DeviseOverride::RegistrationsController < Devise::RegistrationsController
  def create
    super
    if resource.save
      resource.create_profile
    end
  end

R
Roman Mirilaczvili, 2016-06-30
@2ord

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 question

Ask a Question

731 491 924 answers to any question