Note that there are some explanatory texts on larger screens.

plurals
  1. POOverwriting 'Devise::RegistrationsController' with custom create gives NoMethodError
    primarykey
    data
    text
    <p>Please let me know if I'm going about this the wrong way. I'm trying to add a couple custom attributes to a <strong>User</strong> in the create method as well as call my <strong>Analytics</strong> method if the user is saved.</p> <p>I defined a new controller:</p> <pre><code>class RegistrationsController &lt; Devise::RegistrationsController def create build_resource(sign_up_params) resource.public_id = Utilities::generate_code resource.referral_code = Utilities::generate_code if resource.save Analytics.identify( user_id: resource.id.to_s, traits: { email: resource.email }) yield resource if block_given? if resource.active_for_authentication? set_flash_message :notice, :signed_up if is_flashing_format? sign_up(resource_name, resource) respond_with resource, :location =&gt; after_sign_up_path_for(resource) else set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format? expire_data_after_sign_in! respond_with resource, :location =&gt; after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource respond_with resource end end end </code></pre> <p>The only thing different in this create method is that I'm adding <strong>referral_code</strong> and <strong>public_id</strong> before the save and running Analytics after.</p> <pre><code> Analytics.identify( user_id: resource.id.to_s, traits: { email: resource.email }) </code></pre> <p>When I create a user I'm getting</p> <pre><code>undefined method `is_flashing_format?' for #&lt;RegistrationsController:0x007fdba130d9a8&gt; </code></pre> <p>I don't understand why this method isn't being inherited. Is this even the proper way to modify devise or to add attributes/add analytics?</p>
    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