avo
avo copied to clipboard
[Feature] Provide hooks in controller actions
Feature
Provide hooks on create or update after save to perform some actions. Here's what I'm trying to achieve:
class Avo::EmailsController < Avo::ResourcesController
def create
super
# This is not being called
@model.send_as_reply
end
end
Here's how it could work:
class Avo::EmailsController < Avo::ResourcesController
def create
super do |resource|
resource.send_as_reply
end
end
end
Current workarounds
Right now, we can hook onto these actions through ActiveRecord callbacks, but it's not always convenient.
Additional context
A simple and good implementation is the pattern used in the devise controllers, where the resource is being yield if a block is passed : https://github.com/heartcombo/devise/blob/f8d1ea90bc328012f178b8a6616a89b73f2546a4/app/controllers/devise/registrations_controller.rb#L20
It's probably 20 mn of work which I'd gladly take on this week if you find it interesting :)
YES! I want that! That looks amazing!
I launched Avo on Product Hunt (any feedback and comments help a lot BTW) and my efforts go there today. But I'm happy to help more hands-on from tomorrow 💪
Upvoted ✅ Congrats on the launch !
This issue has been marked as stale because there was no activity for the past 15 days.
We're going to use this approach.