nflorentin said over 5 years ago on Nested Forms from Scratch with StimulusJS :
Thanks for this video! I have one doubt though, the `Math.floor(Math.random() * 20` has a high probability to repeat itself. In that case, only one record will be created. Why not generating a more complex number to avoid that ?

David Kimura PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
I wouldn't say high probability in the real world, but yes it would have a chance. one could use `new Date().valueOf()` instead, but it too could be duplicated if using a bot.

nflorentin said over 5 years ago on Nested Forms from Scratch with StimulusJS :
It produces a number between 0 and 20. Imagine you add 15 tasks to your todolist, probability of having a repeated number is almost 100% ... !

David Kimura PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
Lol, this is true. My apologies, I should have mentioned taking out `20` to a higher number like `Math.floor(Math.random() * 10000000000000000000)`. Running on fumes this morning.

rcoproc PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
Congratulations Kobaltz, everything worked properly and great stuff. Thanks for posting on Rails 6 already, a lot of good coming around. A note (maybe) a little bug I found. When entering edit mode of some list to do, I tried to do the inclusion of new lines or remove existing ones and it does not work. No error is shown in console.log. The add new record and delete events only work when I'm in the include mode of the to-do. Hugs and good work.

David Kimura PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
nflorentin mentioned the probability for this occurring. Either take out the `20` number to something much higher or use `new Date().valueOf()`

Tony Dehnke said over 5 years ago on Nested Forms from Scratch with StimulusJS :
I'm a newbie, but wondering if rather than doing the math equation, could you not generate some type of UUID instead? Thanks for making the video, a lot is still over my head, but it's great to watch and see how other people build things.

inopinatus PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
Would be interested in your take on a Vue.js version e.g. using slots.

David Kimura PRO said over 5 years ago on Nested Forms from Scratch with StimulusJS :
I would likely handle it very similar with a Vue controller. The actions on the objects would be slightly modified, but more or less very similar.

ewanchic PRO said almost 4 years ago on Nested Forms from Scratch with StimulusJS :
FYI, Deprecated Warning:
Please replace data-target="nested-form.template" with data-nested-form-target="template". The data-target attribute is deprecated and will be removed in a future version of Stimulus.<template data-target="nested-form.template">

Please replace data-target="nested-form.add_item" with data-nested-form-target="add_item". The data-target attribute is deprecated and will be removed in a future version of Stimulus.<div data-target="nested-form.add_item">

someone PRO said over 3 years ago on Nested Forms from Scratch with StimulusJS :

Any idea's how to get a second nested form's fields in the _task_fields partial to render?  in this example the nested car_field doesn't display on the main _form. 


# _task_fields.html.erb
<div class='nested-fields'>
  <div class='form-group'>
    <%= form.hidden_field :_destroy %>
    <%= form.text_field :description, placeholder: 'Description', class: 'form-control' %>
           <%= form.fields_for :car do |car_field| %>
              <%= car_field.text_field :engine%>
           <% end %>
    <small>
      <%= link_to "Remove", "#", data: { action: "click->nested-form#remove_association" } %>
    </small>
  </div>
</div>

David Kimura PRO said over 3 years ago on Nested Forms from Scratch with StimulusJS :
If it is nested forms within nested forms, have a look at this episode where I addressed this episode's issues with that. https://www.driftingruby.com/episodes/gathering-questionnaire-responses

Login to Comment