I’m seeking some general advice on how to go about this problem. (I’m using rails)
I have a list of customers. I am listing only their names in an index action. When the name is clicked i want to retrieve further information from the server concerning each particular customer. viz:
<% @customers.each do |customer| %>
<%= customer.name %>
<-- when you click on the customer name, I want further details to appear -->
<-- I want to append the customers/_show.html.erb partial here when the customer name is clicked -->
<% end %>
<-- more information re: the customer is shown in this partial -->
<%= customer.date_of_birth %>
<%= customer.address %>
I suppose there are two ways which one can do this:
- Using plain vanilla ajax with a
customers/show.js.erbtemplate which appends the partial to the DOM.
- Another method using Stimulus js erb controller and then using a
Was wondering how some of you folks would go about solving this particular problem?