DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

Override the included gem method by using hock.

πŸ’Ž I did it with DeviseInvitable

gem 'devise_invitable'

πŸ¦„ There is a great hook!!

Alt Text

πŸ‘ How to use it?

  • I give a block to the super.
    • super do is the same as super(attributes, invited_by) do.
  • Then, the block will be evaluated at the yeild method.
def self.invite!(attributes = {}, invited_by = nil, &block)
  super do |invitable|
    invitable.user = special_user
  end
end

πŸ”— Parent Note

Top comments (0)