Doesn't :allow_destroy help on you use cases? On Mon, Jan 27, 2020 at 2:16 PM Micah Geisel <originofsto...@gmail.com> wrote:
> Okay, just released version v0.2.0, which expands support to Ruby 2.5, > 2.6, and 2.7, and Rails 5.1, 5.2, and 6.0. No changes to the code needed to > be made, it turns out. Probably works on older Rubies and Rails, too, but > this was the low hanging fruit. PRs welcome for more support. > > Rails core folks: would submitting a PR at this point be premature? I'm > not clear on how this process works. > > On Friday, January 24, 2020 at 9:23:11 AM UTC-8, Micah Geisel wrote: >> >> Hi Mehmet! That's great to hear! I had tried accomplishing this via >> lifecycle hooks, and then via setters, and found that it was really hard to >> cover all the edge cases, and that it felt like I was fighting with the >> functionality in .accepts_nested_arguments_for. Glad to hear that its not >> just me who has a use for this. Knowing that you're using it, I'll fill out >> the Travis testing matrix to test more rubies and rails, instead of just >> the combo my app is using. >> >> On Friday, January 24, 2020 at 8:29:29 AM UTC-8, Mehmet Aydoğdu wrote: >>> >>> 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: >>>> >>>> https://github.com/botandrose/active_record-nested_attributes-destroy_if >>>> >>>> >>>> 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 >>>> <https://groups.google.com/d/msgid/rubyonrails-core/6fa3f3a2-5637-4471-9eae-ae667907e255%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> >>> >>> [image: --] >>> >>> >>> Mehmet Aydoğdu >>> [image: https://]about.me/mehmetaydogdu >>> >>> <https://about.me/mehmetaydogdu?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links> >>> >> -- > 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-core+unsubscr...@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 > <https://groups.google.com/d/msgid/rubyonrails-core/437183f1-8817-4fab-94da-2ea15b12bd33%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAA2Dq%2BPUsium%2Bjy8vDnTPBQYJWC1PdqEDSLhyQQuja0CuYy85A%40mail.gmail.com.