intercom / intercom-rails

The easiest way to install Intercom in a Rails app.
https://developers.intercom.io/reference
MIT License
281 stars 108 forks source link

Also block controllers inherit from Devise::Passwords controller #339

Closed Zhong-z closed 3 years ago

Zhong-z commented 3 years ago

Why?

Sometime we need to customise some logic of devise, which usually done via inheritance of Devise::Passwords controller. However, the script would get injected because the class name is no longer Devise::PasswordsController

How?

This fix checks all the ancestors of the current controller and intersect with BLOCKED controller names, and block when there is positive count.

Alternatively, we could use superclass.name instead of class.ancestors.map(&:name), however this is limited to only 1 level of inheritance from Devise::PasswordsController

Zhong-z commented 3 years ago

Closing as the same can be achieved by including skip_after_action :intercom_rails_auto_include in the inherited controllers