-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
"missing attribute: state" when state attribute is not included in the query #76
Comments
Can you give me an example model and corresponding query to reproduce this? |
http://pastie.org/private/n3r0focjcdges7durjog |
It fails here.
|
Thanks for the report, I'll look into this as soon as I can. |
This was broken in bf5d2b6 by adding Mongoid support. Using We now just use 0.1.4. |
I just reverted: #68 |
Hey, thanks a lot, looks like it's working.
multiple times. |
Not sure why you get that but this was added in a recent pull request: https://github.com/troessner/transitions/pull/73/files#L1R47 The same here for me:
I have a more or less vanilla rails app - seems like this happens because more than one model use @cmw do you see what's going wrong here? |
@troessner yeah, a bunch of my models include AM::T |
I get a nice
|
@maser can you do me a favor and narrow it down for me a litte? This means:
and check if it's working again.
and see if it fails. |
@troessner Yes, we are using 0.1.4 for now. b2e64fe and 1304a15 work as you expected them to, so your fix works. Thanks! There is a new arning, though: |
Also from what you said I am not sure if this still affects the current version. Does
mean that it works for you now with v 0.1.6? If not, can you tell me how to reproduce this error? Because I'm using 0.1.6 in multiple rails apps and have no problems so far. |
@troessner Sorry, I wasn’t clear enough. b2e64fe works, 1304a15 does not, neither does 0.1.6. I can try to reproduce the error in a clean app tomorrow. |
I cannot reproduce the problem in a new Rails application. I’ll have to test if there is an incompatibility with some other part of the application (it is large enough for that to take some time though). |
The warning WARNING: Transitions::Machine#new_update or Transitions::Machine#new_initialize already defined. This can possibly break ActiveModel::Transitions just means that AM::T got loaded more than once and the condition prevented the aliasing block from producing endless loops. I only included the warning because it's conceivable, that Transitions::Machine#new_initialize could be defined before the module is added. This will potentially break something, so, if things don't seem to work right, this is a pointer to where the problem might be. |
@cmw I get the warning multiple times each time Rails is loaded. I have multiple models with state machines, all the models include ìnclude ActiveModel::Transitions`. ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.send(:extend, ActiveModel::Transitions)
end as a workaround, but apparently that fails too because the columns are not yet defined on the model at that point and AM::T tries to find the Trying to extend AR later in the lifecycle doesn't work either as the |
@cmw I see your point, however this warning can get annoying pretty quick - how about removing this warning and use some method name we're sure nobody else uses, like |
@troessner would that solve the warning popping when AM::T is included multiple times in different models ? |
We wouldn't necessarily have to display the warning in that case (though we still need the check to protect from endless loop). Not a bad idea, though of course we can't really know that nobody uses a method with that name. |
Yes.
Yeah, then let's drop it.
True, but I'd say the chances are so low that we should go with it ..:) Do you have the time to whip up a pull request? I can do it as well but unfortunately I'm pretty loaded for the next few days. |
@troessner You got it :) |
Alright, I just released 1.0.7 with all the latest and greatest..;) @davout the warnings should be gone now -> Closing this. |
Works perfect. Thanks a lot! |
@troessner I still get it, but I won’t open an issue before I know how to reproduce this. |
Not sure if I should open a new issue, but I'm getting this again. ruby 2.0.0
|
This reverts commit bf5d2b6. because of: troessner#76 Conflicts: lib/active_model/transitions.rb
When selecting aggregates with custom SQL the error is raised.
It worked perfectly in 0.1.4 but broke in 0.1.5
The text was updated successfully, but these errors were encountered: