-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Record rendered too early when adding validation #367
Comments
Hi @Tao-Galasse, |
Thanks for the quick answer :) |
I honestly have no idea :D If it was me, I'd be using breakpointing (or just Are you using Rails 5? If not, they seem to have fixed some inaccuracies with regards to relation counting: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/validations/length.rb#L3-L10 |
The point is that the validation doesn't fail :/ I checked my logs too and the SQL transactions are the same with or without the validation. The point here is in the controller: it seems like I'm using Rails 6. |
That's very strange. Definitely sounds like a bad interaction between |
Closing due to inactivity. |
Hi !
I encountered a quite hard-to-explain bug with acts_as_list.
I have a
plant
which has_manyplant_stages
, so PlantStageacts_as_list scope: :plant
.When I update a plant to change position of a plant_stage in my controller, everything's fine : the plant and the plant_stages rendered by the api are correctly updated.
But, when I add a validation on my
Plant
model to ensure a plant has at least one plant_stage, something wrong happen :the plant and the plant_stages rendered by the api are not correct : the positions are not updated. BUT, in the database, everything's fine, so it seems like the plant in the controller is rendered BEFORE the plant_stages have been updated.
(I hope I've been clear).
Here is my controller method:
What I think is the positions of the plant_stages are updated after the
update
method on @plant.So @plant is rendered when it has been updated, but before the plant_stages positions have been updated, so the api is rendering wrong data even if it's correct in the database.
any help would be greatly appreciated 🙏
(if it wasn't clear / need more details, just tell me 😃)
The text was updated successfully, but these errors were encountered: