Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you have a User model with a <code>has_one</code> Profile association, you simply need to allow nested attributes in User and modify your devise registration view.</p> <p>Run the <code>rails generate devise:views</code> command, then modify the devise <code>registrations#new.html.erb</code> view as shown below using the <code>fields_for</code> form helper to have your sign up form update your Profile model along with your User model.</p> <pre><code>&lt;div class="register"&gt; &lt;h1&gt;Sign up&lt;/h1&gt; &lt;% resource.build_profile %&gt; &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name)) do |f| %&gt; &lt;%= devise_error_messages! %&gt; &lt;h2&gt;&lt;%= f.label :email %&gt;&lt;/h2&gt; &lt;p&gt;&lt;%= f.text_field :email %&gt;&lt;/p&gt; &lt;h2&gt;&lt;%= f.label :password %&gt;&lt;/h2&gt; &lt;p&gt;&lt;%= f.password_field :password %&gt;&lt;/p&gt; &lt;h2&gt;&lt;%= f.label :password_confirmation %&gt;&lt;/h2&gt; &lt;p&gt;&lt;%= f.password_field :password_confirmation %&gt;&lt;/p&gt; &lt;%= f.fields_for :profile do |profile_form| %&gt; &lt;h2&gt;&lt;%= profile_form.label :first_name %&gt;&lt;/h2&gt; &lt;p&gt;&lt;%= profile_form.text_field :first_name %&gt;&lt;/p&gt; &lt;h2&gt;&lt;%= profile_form.label :last_name %&gt;&lt;/h2&gt; &lt;p&gt;&lt;%= profile_form.text_field :last_name %&gt;&lt;/p&gt; &lt;% end %&gt; &lt;p&gt;&lt;%= f.submit "Sign up" %&gt;&lt;/p&gt; &lt;br/&gt; &lt;%= render :partial =&gt; "devise/shared/links" %&gt; &lt;% end %&gt; &lt;/div&gt; </code></pre> <p>And in your User model: </p> <pre><code>class User &lt; ActiveRecord::Base ... attr_accessible :email, :password, :password_confirmation, :remember_me, :profile_attributes has_one :profile accepts_nested_attributes_for :profile ... end </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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