Override the included gem method by using hock.

twitter logo github logo ・1 min read

πŸ’Ž 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

πŸ”— Parent Note

twitter logo DISCUSS
Classic DEV Post from Dec 15 '19

VS Code + GitHub Gist = Developer Micro-Blogging (aka a "GistLog")

n350071 profile image
Ruby Web Developer. Freelancer.