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
Initial state doesn't work with rails 3.2 #150
Comments
Nice catch! Hopefully now that I'm hooking into a public API, this shouldn't break again anytime soon. I'm probably going to wait on releasing this fix until 3.2 is a little closer to be officially released. |
Any thoughts on a release now that rails is on 3.2.2? We've been updating a rather large app and would rather not use git for the source :) |
Hi @brentkirby - This fix was released in state_machine 1.1.2. |
hmm. I was having the same issue with 1.1.2, and ended up writing a before_create callback to set the default state, which fixed it. It was actually working fine until updating from rails 3.1.4 to 3.2.2, which is when I first started having trouble. |
Interesting -- I'll double check against the latest 3.2.x release, but everything is passing on 3.2.1. Could you provide an example of this failing? If you have a basic project that you could share on github that demonstrates the issue, that'd be great! |
Heres a gist of the actual state machine functionality. I had it in a separate module since the model that includes it is huge :) After updating to 3.2.2, tons of specs started to fail with ActiveRecord::RecordInvalid, saying "state" is invalid. Adding the before_validation callback fixed it.
|
Nothing stands out indicating where the issue might be and I can't reproduce the issue based on your gist. Any chance you could provide a full example (including project) that I can run demonstrating the issue? |
I'm getting the same in 3.2.3 (https://gist.github.com/c13a36cec659a1396e5e). I tried making attr_accessible in case that was an issue, but no dice. Have used brent's before_validation trick (thanks!). |
I'd love to be able to see a project repo demonstrating this issue so that I can reproduce it locally and get it fixed. Would either of you be able to do that? |
I can't publish the current app public as it's client work but I'll dummy one for you later when I get home :) |
Ok, try this simple example project. It has the behaviour I mentioned. Details are in the README. |
Hey @urfolomeus - That project is bundled with state_machine 1.1.0. The fix for ActiveRecord 3.2+ was in state_machine 1.1.2. Updating the |
I was sure I'd set it to the latest version. Humble apologies. crawls under rock cheers, Alan On Monday, 30 April 2012 at 12:56, Aaron Pfeifer wrote:
|
Glad we were able to figure it out :) |
Hey all, I got questions, first of which is I'm using > bundle list | grep state * state_machine (1.1.2) * state_machine-audit_trail (0.1.0) * railis 3.2.2 #btw The initial state isn't being set. In my controller, i had to jerry-rig it with I was having a big time fail with FactoryGirl, of course seeing the readme after. I'm going to open up another ticket with what i've got in my model... maybe it's something I'm doing. But i'm following the docs. |
Hi.
Setting default state doesn't work in rails 3.2 (branch 3-2-stable).
Sample app reproducing issue:
https://github.com/morgoth/state-machine-rails-3-2
I tried rails revision:
6e9cd3846811718611543dae049c000076319587
(it's working fine when using gem 3.2.rc1)The text was updated successfully, but these errors were encountered: