Comments (11)
just got bitten by this bug myself.
from aasm.
Yeah, and you'd think that more people would be experiencing this. There are 556 watchers.
from aasm.
I forked the repo and fixed the error @ http://github.com/Jaryl/aasm/tree/master. Now, how does this thing work, should I leave it at this or do I submit a pull request or what?
from aasm.
Note that the newest documentation (or at least the source as of version 2.1.5) now just says "Writes state to the state column and persists it to the database", which means that your state will not be persisted unless the object validates.
from aasm.
Iwu, you are right. You may want to follow the discussion here:
http://rubyist.lighthouseapp.com/projects/13207/tickets/18-state-transitions-do-not-persist-to-db-in-activerecord-models
from aasm.
My belief is that if the model is in a state which is currently invalid, the transition should fail if only to prevent further invalidation.
Even if the state transition would make the model valid, the potential of having an invalid model persisted only creates more confusion.
Perhaps a solution would be to check if the model is valid before attempting transitions.
from aasm.
I'm currently using state_machine in my projects, which provides facility to validate/invalidate state changes, in case any of you are shopping around.
from aasm.
So, what do you expect to happen? Returning false if trying to change the state of an invalid object? Or do you prefer to throw an exception?
from aasm.
I would expect that a state change would either raise an exception or return false.
Just like in AR::Base#update_attributes!
vs. AR::Base#update_attributes
.
The main thing is that the transition did not occur.
from aasm.
Okay, I see. If the state is not changed, then it's a bug, and I'll fix it soon.
from aasm.
I just released version 3.0.2, where I added a switch to the aasm configuration (:skip_validation_on_save) to make sure that states are stored to the database even if the model is invalid. Look at the readme on https://github.com/rubyist/aasm, section 'Persistence example' how to apply it.
from aasm.
Related Issues (20)
- Timestamps column name with enum and _prefix HOT 1
- Active Record upgrade 5 to 6 : AASM does not clear the activerecord cache after calling an event HOT 2
- I have a question
- AASM and graphql
- Tag releases v5.3.1, v5.4.0 and v5.5.0 HOT 1
- Invalid error is not using locale setup in the application
- Custom auto-save feature
- Namespaced scopes perform incorrect queries HOT 2
- raising in aasm_fire_event does not rollback transaction HOT 1
- Multiple state machines per class don't work properly with automatic scopes HOT 1
- Multiple state machines per class don't work properly with automatic state constants HOT 2
- Can't pass an empty hash as callback parameters to `transition_from` since 5.5.0 HOT 2
- callbacks endless loop HOT 2
- Update RSpec helper to reset states with `binding_event`
- Can't pass arguments on events with bangs in Ruby 3.0 HOT 14
- Stopping event without raising from after callback HOT 1
- gem misses CHANGELOG HOT 1
- Performance of aasm_ensure_initial_state (end Rails 3 support?) HOT 1
- Callback with positional and keyword args errors out in Ruby 3.2
- Revisit "Add :after_commit callbacks to events"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aasm.