title: Rails 4 Devise Call Back on Registration
body: <p>I have two models</p>
  <blockquote>
  <p>User(id, name, is_host,....)</p>
  <p>Host(id, name, user_id,...)</p>
  </blockquote>
  <p>With the Association</p>
  <blockquote>
  <p>User hasOne Host</p>
  </blockquote>
  <p>I am using Devise for the User Registration. When a user wants to register as a Host i want to set <code>is_host = 1</code> and <code>create a row in Host</code> with the <code>name</code> of the Host he provides in the Registration Form.</p>
  <p>What i want to do?</p>
  <ol>
  <li>Allow Registration Form to accept Host details</li>
  <li>Create the association data when user selects <code>register as host</code></li>
  </ol>
  <p>Am trying to figure where i can write the logic based on what the user chooses to register as and then create the associated row in Host.</p>
  <p>User From</p>
  <pre><code>&lt;%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %&gt;
    &lt;%= devise_error_messages! %&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :first_name %&gt;&lt;br /&gt;
      &lt;%= f.text_field :first_name, autofocus: true %&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :last_name %&gt;&lt;br /&gt;
      &lt;%= f.text_field :last_name %&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :email %&gt;&lt;br /&gt;
      &lt;%= f.email_field :email %&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :password %&gt;
      &lt;% if @validatable %&gt;
      &lt;em&gt;(&lt;%= @minimum_password_length %&gt; characters minimum)&lt;/em&gt;
      &lt;% end %&gt;&lt;br /&gt;
      &lt;%= f.password_field :password, autocomplete: &quot;off&quot; %&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;% f.label :password_confirmation %&gt;&lt;br /&gt;
      &lt;% f.password_field :password_confirmation, autocomplete: &quot;off&quot; %&gt;
    &lt;/div&gt;
  
    &lt;div class=&quot;field&quot;&gt;
      &lt;%= f.label :is_host %&gt;&lt;br /&gt;
      &lt;%= radio_button(&quot;user&quot;, &quot;is_host&quot;, true) %&gt; Yes
      &lt;br/&gt;
      &lt;%= radio_button(&quot;user&quot;, &quot;is_host&quot;, false) %&gt; No
    &lt;/div&gt;
  
    &lt;div class=&quot;actions&quot;&gt;
      &lt;%= f.submit &quot;Signup&quot; %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>