someone PRO
Joined 5/14/2020
someone PRO said almost 3 years ago on Removing Friendly Id :
So in my app I'm using the slugs to represent titles in posts instead of showing the post numbers. I had originally asked how to stop the UUID from changing each time a duplicate record was updated because it would break bookmarks.  I deleted the question though because I foolishly thought at first that all I had to do was remove "before_update :generate_slug" from sluggable.rb.  But as I later realized this may stop a UUID from changing when the duplicate post title gets updated, however it will not change the title in the url anymore.  So if someone were to change the title of a post from "XXX" to "YYY" it would still show the old "XXX" in the url even though the post itself had the new title.  

So after a little digging I found this simple fix that checks if the title field has been changed and only runs the generate_slug function if it has.  basically you just need to append "if: <some_field>_changed?" to any field you want to check.  This now allows for duplicate titles that have UUID's to keep their original UUID when updating unless the title has explicitly been changed to a new title, the UUID might be deleted if it no longer is a duplicate or a new UUID is generated only if it is a duplicate of a different title.   

    before_update :generate_slug, if: :title_changed? 

     

someone PRO said almost 3 years ago on Authentication from Scratch :
Good video, would definitely like to see a follow up with password resets implemented and confirmation emails.  Thanks.

someone PRO said almost 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>

someone PRO said about 2 years ago on Rails 7 with Esbuild and TailwindCSS 3.x :
Yes, Tailwind UI.  I ended up installing Alpine.js in my app and using that to get Tailwind UI working.  

someone PRO said almost 2 years ago on Benchmark Ruby Code :
Rails has now added a benchmark generator which is pretty helpful.

rails g benchmark some_benchmark

it creates the file at 
script/benchmarks/some_benchmark.rb

It should automatically add the ips-benchmark gem to your gemfile after running bundle but if it doesn't just add it under the development section in your gemfile.  

run it in the terminal by doing 
ruby script/benchmarks/some_benchmark.rb

since it loads config/environment.rb in the benchmark file all models are accessible.