'Rails 6 Showing unknown key :on

before_save :balance_status, :on => :update

it is throwing "Unknown key: :on. Valid keys are: :if, :unless, :prepend" in Rails-6



Solution 1:[1]

before_save is used for both create and update. You should use before_update :balance_status instead.

Solution 2:[2]

In rails 6 the option on does not exists for before_save, see the official documentation for more info. You can use before_commit.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SirTune
Solution 2 Carlos Jiménez