DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

1

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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay