Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danmaz74 opened this issue Mar 7, 2014 · 5 comments
Open

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

danmaz74 opened this issue Mar 7, 2014 · 5 comments

Comments

@danmaz74
Copy link

danmaz74 commented Mar 7, 2014

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?

@seuros
Copy link

seuros commented Mar 7, 2014

vehicle.seatbelt = 'off' => vehicle.update_attribute(:seatbelt , 'off') if you using activerecord.

The gem is for general use so it won't save the object

@danmaz74
Copy link
Author

danmaz74 commented Mar 7, 2014

That's ok for me, but the docs should be updated then. They're very misleading now.

@seuros
Copy link

seuros commented Mar 7, 2014

The docs are not important for now. The whole gem is not maintained and is incompatible with new version of rails or mongodb for example.

@jeremywadsack
Copy link

Is this what you mean #291?

@cawel
Copy link

cawel commented Apr 7, 2016

@seuros Stating that the "docs are not important for now" is a rather bold statement, considering the fact that this project has been starred more than 3000 times (i.e. lots of people are using this gem) and that the readme (wrongly) states that this gem supports the latest version of rails. Indeed, quoting the readme:

ORM versions officially supported and tested:
ActiveModel integration: 3.0.0 or later
ActiveRecord integration: 2.0.0 or later

I'm currently on a project using this state_machine gem and I am having issues with the after_transition callback. But only now (reading that thread – rather than the readme), I understand that the gem is not expected to work with the latest version of rails.

Suggestion: I think the project's readme should make it clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants