Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a user profile upon registration add profile form fields to devise registrations#new form
    primarykey
    data
    text
    <p>I have a rails 3.1 app with devise:</p> <ul> <li>User has_one profile</li> <li>Profile belongs_to user</li> <li>Overruled the devise registration_controller</li> <li>Custom registration views all working fine, registration works fine</li> </ul> <p>Now I could like to add this:</p> <ul> <li>On the registration page I want to add fields from the profile, like first name, lastname</li> <li>There is no user yet, that is going to be created when submitting the form</li> <li>I need the profile to be created with this first name,last </li> </ul> <p>How would I do this? I tried several ideas, also from stack overflow but cannot seem to get it working. I tried nested attributes wich is not working the way to do this would to create a profile record in the db at the moment the user registers wich inserts the first name and last name</p> <p>My registrations#new view:</p> <pre><code>= simple_form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name)) do |f| = devise_error_messages! = f.input :username, :label =&gt; 'Username' = f.input :email, :label =&gt; 'Email' = f.input :password, :label =&gt; 'Password' = f.input :password_confirmation, :label =&gt; 'Password confirm' // start fields for profile = f.fields_for :profile do |f| = f.label :bod_day = f.text_field :bod_day // end fields for profile = f.button :submit, t(:submit, :scope =&gt; :register) </code></pre> <p>In my user model i have this:</p> <pre><code> accepts_nested_attributes_for :profile </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload