-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Rails 4.0 - bring back in-place editing support for collection associations #12236
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
Conversation
…d::Delegation" This reverts commit 1a40be0. Conflicts: activerecord/CHANGELOG.md
I think I'm missing something. Are not the in-place edit, methods still deprecated in your PR? |
Not for the CollectionProxy - it overrides array_delegate(). |
… on respond_to?() result
I think you missunderstood. This behavior was changed by design. We choose to not support this in Rails 4.0 and we will not bring it back. |
Thank you for your pull request. |
Can I see the discussion somewhere ? |
Unfortunately no. It was in our private campfire room |
Can you tell In two words - why did you chose to do that? |
But this change is on the CHANGELOG entry 0a6833b |
Because it causes confusion where you think you are changing the relation/association and you actually is not. The database is still the same. |
Sorry but all that I can see is more awkward code instead has_many.select!{ my records } I'll have to do has_many = has_many.select{ my records } , the results is the same only more difficult to achieve. |
and with more array dupping |
Yup, this is another thing we want to avoid. This kind of operation is not performatic if you have a huge set of data. If you want to do select you should be using the query interface, not the array methods. |
But if you want to do in-place editing you still can: has_many_array = has_many.to_a
has_many_array.select! { } |
Yea I know that but how can I tell back to the association that it should unlink some records when the owner is saved?, This hurts autosave cascading. |
Using |
As far as I see this is instant and will not bundle with owner save transaction. Am I wrong? |
You can also set the association. |
Which brings us exactly where we started - I'll have to use assignment to throw out some comments. |
Yes. And it is fine. I don't see any problem on using it. The decision was already made and like I said we will not change it back since it introduce more confusion than feature. We prefer to make the things explicit. Thank you for the discussion. |
Ok - beer for all of you people! Just a few final questions: Anyway it was really nice discussion. |
@georgiev These are good point. I'll ask the Core teams opinions on this subject. |
@rafaelfranca "Because it causes confusion where you think you are changing the relation/association and you actually is not. The database is still the same." ^ Really? Who would think that? That's ridiculous. You seem to be designing for people that have very little understanding of the system that they're working on, rather than the common case. Further, a single statement of warning in documentation should solve this problem. Someone would need to try it only once to understand. This direction seems so inconsistent with the entire concept of editing ActiveRecord objects in memory. |
@joshjordan 💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙💚💛❤️💜💙 |
This PR is related to
#12140, #12213, 1a40be0 and #12227
Since personally I'm very unhappy with the way the resolution of these issues is heading, and I thing it's killing the fun in Rails and forces me to write awkward code - here goes my offer