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)