Skip to content

Saving in after_transition on AR: Bug or bad docs? #305

@danmaz74

Description

@danmaz74

The docs for ActiveRecord show this:

after_transition any => :parked do |vehicle, transition|
vehicle.seatbelt = 'off'
end

I would then expect that the new value for vehicle.seatbelt would be saved to the database. But this doesn't happen (state_machine v. 1.2, rails v. 3.2.15): the attribute is changed, but if I reload from the DB, it goes back to the old value.

On the contrary, the new value gets saved in a before_transition.

Is this a bug, or just something that should be clarified in the documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions