Nofly takes your logic for emails and other notifications out of the controller and put it into its own context
When we send communications to users it is usually in response to an event. Users often have their own communications preferences (when/how/what).
This logic can easily become complicated and so I developed Nofly to abstract it and let the core application only worry about knowing what event happened to which object/record.
class FooController < ApplicationController
def bar
@foo = Foo.create foo_params
Nofly.for(@foo).bar
end
end
class FooNofly < Nofly::EventLibrary
// check user preferences
// send emails,
// send push notifications
// etc.
end
Add an autoload path for the directory you’ll keep your nofly config.autoload_paths += Dir to application.rb
Notifications shouldn’t be done on the fly, and Ruby gems already has a ‘Notifly’