Sorry, typo in 3. Should be :reject_if, not :ignore_if.

On Tuesday, January 28, 2020 at 7:07:47 AM UTC-8, Micah Geisel wrote:
>
> Yes, I could write some JavaScript to inspect the text fields on their 
> change event, and then toggle a hidden _destroy param to cover the third 
> use-case, but this has some significant downsides, compared to :destroy_if 
> solution that I'm proposing here.
>
> 1. Decreased locality. Logic to handle nested params would be both in the 
> model, and also in the client in JavaScript
> 2. Increased complexity. The JavaScript component is more lines of code, 
> and thus more things that can go wrong. What if the client is running 
> NoScript, etc?
> 3. Code duplication. The predicate logic that is passed to :ignore_if 
> would have to also be written in JavaScript.
>
> Compared to this, :destroy_if appears to be a much simpler and cleaner 
> solution, and has none of these downsides.
> .
> On Tuesday, January 28, 2020 at 2:03:36 AM UTC-8, Pedro Fernandes 
> Steimbruch wrote:
>>
>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/rubyonrails-core/5580a000-b636-4781-9649-7fedbb80432f%40googlegroups.com
>>> .
>>>
>>

-- 
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/df938809-678b-4696-9978-3944df47dc24%40googlegroups.com.

Reply via email to