--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/6fa3f3a2-5637-4471-9eae-ae667907e255%40googlegroups.com.
I cleaned several methods in the models using the package. It is nice to handle this feature in one line, thanks.
Micah Geisel <origino...@gmail.com>, 24 Oca 2020 Cum, 03:41 tarihinde şunu yazdı:
Howdy, folks!--I'd like to suggest adding a stronger version of the :reject_if option to the .accepts_nested_attributes_for class method, one that not only prevents new records from being added, but also destroys existing records, using the same supplied logic.Use-case:A person has many email addresses, and the person wants to update their profile by adding and removing email addresses in a form. This form is designed to be a simple list of text fields, one for each email address. Users can update an existing email address by simply editing the text field, create a new email address by filling in a new text field, and remove existing email addresses by clearing out a text field. Simplicity and consistency is the goal here.However, .accepts_nested_attributes_for's :reject_if option only permits 2/3 of these use-cases, so I have created a gem that adds a new :destroy_if option, and this permits all three use-cases! I am posting here to see if there is interest in merging this (in one form or another) into ActiveRecord itself. More details are in the README of the gem:What do y'all think? Feedback very welcome. Thank you for your time!
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/6fa3f3a2-5637-4471-9eae-ae667907e255%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/437183f1-8817-4fab-94da-2ea15b12bd33%40googlegroups.com.
My understanding is that :allow_destroy simply enables the _destroy param. Is this not the case, and I'm reinventing existing functionality?
https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
Rereading the documentation, it appears as though my understanding is correct. If it's not, though, that would be great. I'd love to already have this functionality!
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/5580a000-b636-4781-9649-7fedbb80432f%40googlegroups.com.
Hey,you're right in your understanding. :allow_destroy will enable the _destroy param and in your use case, can't you send the _destroy in the request?
On Mon, Jan 27, 2020 at 10:30 PM Micah Geisel <origino...@gmail.com> wrote:
Hello, Pedro! Thank you for the message.
My understanding is that :allow_destroy simply enables the _destroy param. Is this not the case, and I'm reinventing existing functionality?
https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
Rereading the documentation, it appears as though my understanding is correct. If it's not, though, that would be great. I'd love to already have this functionality!
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.