aasm icon indicating copy to clipboard operation
aasm copied to clipboard

Whiny_persistence should be true as default

Open andresespinosapc opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. I wasn't aware that the events with bangs didn't raise an error when validation fails.

This is unconsistent with ActiveRecord methods' behaviour.

Describe the solution you'd like

  1. Whiny_persistence's default value should be true
  2. It should be possible to change the defaults application-wide in an initializer.

Describe alternatives you've considered Doesn't apply

andresespinosapc avatar Mar 15 '22 20:03 andresespinosapc

Sounds like you're using Rails. As a workaround, I wrote an ActiveSupport::Concern for this that seems to work well enough

# AASM + extensions
# You should ONLY `include` this module since it `include`s AASM directly
module AasmExtensions
    extend ActiveSupport::Concern

    included do
      # These parameters should be shared by all AASM instances
      # i.e. aasm(..., **AASM_ARGS) do ... end
      AASM_ARGS = {
        logger: Rails.logger,
        whiny_persistence: true
      }

      include AASM
    end
end

As noted, you can then use aasm(..., **AASM_ARGS) do ... end on all your state machines.

steamwings avatar Aug 24 '22 16:08 steamwings

Also apparently a PR for your first request has been open for a long time https://github.com/aasm/aasm/pull/378

steamwings avatar Aug 24 '22 17:08 steamwings