We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12f6ac0 commit 7899461Copy full SHA for 7899461
guides/source/active_record_callbacks.md
@@ -983,7 +983,7 @@ class Author < ApplicationRecord
983
has_many :books, before_add: :check_limit
984
985
private
986
- def check_limit
+ def check_limit(_book)
987
if books.count >= 5
988
errors.add(:base, "Cannot add more than 5 books for this author")
989
throw(:abort)
@@ -1004,7 +1004,7 @@ callback for you to use.
1004
class Author < ApplicationRecord
1005
has_many :books, before_add: [:check_limit, :calculate_shipping_charges]
1006
1007
1008
1009
1010
0 commit comments