J'utilise des itinéraires imbriqués dans l'application mes rails. Je suis capable de relier à travers à clients/:id/invoices/:id
Le problème que je rencontre est je pense que j'utilise des routes peu profondes, donc après avoir cliqué un invoice
show link
mon application redirige de /client/:id
à /invoice/:id
. Maintenant, quand j'essaie de revenir de ce lien show
à mon client_path
je reçois les deux routes se mélangeant.Impossible de lier_à corriger le chemin lorsque vous utilisez des itinéraires peu profonds imbriqués
par exemple invoice/34
devient client/34
lorsque je tente de link_to
mon chemin client quand il doit changer la clients id
.
Je pense que cela pourrait avoir quelque chose à voir avec mon action show
dans mon clients_controller
être @client = Client.find(params[:id])
Mes itinéraires
resources :clients do
resources :invoices, shallow: true
end
Mes clients contrôleur montrent l'action
def show
@client = Client.find(params[:id])
@invoices = @client.invoices
end
clients show.html .erb
<% @invoices.where(published: false).each do |invoice| %>
<tr>
<td><%= invoice.sender %></td>
<td><%= invoice.reciever %></td>
<td><%= invoice.amount %></td>
<td><%= invoice.currency %></td>
<td><%= invoice.date %></td>
<td><%= link_to 'Show', invoice_path(invoice) %></td>
</tr>
<% end %>
et ma facture show.html.erb
<%= link_to 'Back', client_path, class: "btn btn-primary" %>
Merci :) '<% = link_to 'Retour', chemin_client (@ invoice.client), classe:" btn btn-primary "%>' travaillé – Aloalo