用自定义create覆盖’Devise :: RegistrationsController’会产生NoMethodError

如果我以错误的方式解决这个问题,请告诉我。 我正在尝试在create方法中向User添加一些自定义属性,并在保存用户时调用我的Analytics方法。

我定义了一个新的控制器:

class RegistrationsController  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 => after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource respond_with resource end end end 

这个创建方法唯一不同的是我在保存和运行Analytics之后添加了referral_codepublic_id

  Analytics.identify( user_id: resource.id.to_s, traits: { email: resource.email }) 

当我创建一个用户时,我正在获得

 undefined method `is_flashing_format?' for # 

我不明白为什么这个方法没有被inheritance。 这甚至是修改设计或添加属性/添加分析的正确方法吗?

我想通了,我正在使用Devise 3.1.1版(锁定依赖项),它看起来像is_flashing_format? 上个月在3.2.0中添加了。

我将控制器中的方法更改为is_navigational_format? 一切都很好!