Commit b2f4e3c 1 parent 6199c82 commit b2f4e3c Copy full SHA for b2f4e3c
File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,34 @@ This invocation will create a single `Noticed::Event` record and a `Noticed::Not
399
399
- An individual delivery job for `:email` method to the second thread author
400
400
- Etc...
401
401
402
+ # ### Tip: Define recipients inside the notifier
403
+
404
+ Recipients can also be computed inside a notifier :
405
+
406
+ ` ` ` ruby
407
+ class NewCommentNotifier < ApplicationNotifier
408
+ recipients ->{ params[:record].thread.all_authors }
409
+
410
+ # or
411
+ recipients do
412
+ params[:record].thread.all_authors
413
+ end
414
+
415
+ # or
416
+ recipients :fetch_recipients
417
+
418
+ def fetch_recipients
419
+ # ...
420
+ end
421
+ end
422
+ ` ` `
423
+
424
+ This makes the code for sending a notification neater :
425
+
426
+ ` ` ` ruby
427
+ NewCommentNotifier.with(record: @comment, foo: "bar").deliver
428
+ ` ` `
429
+
402
430
# ## Custom Noticed Model Methods
403
431
404
432
In order to extend the Noticed models you'll need to use a concern and a to_prepare block :
You can’t perform that action at this time.
0 commit comments