The rails scaffolding generator creates delete links as objects in index views so why when I google how to pass params to a delete link all the answers are examples where a path is used My links don’t have a path, they have an object That’s rails out of the box Like this:
<% @press_releases.each do |pr| %>
<%= link_to 'Edit', edit_press_release_path(pr) %>
<%= link_to 'Delete', pr, method: :delete, data: { confirm: 'Are you sure?' } %>
I didn’t write the above code, rails generated it I tried using delete_press_release_path but there was no such route available So how do I pass an additional parameter in this link please Thanks in advance
The rails scaffolding generator creates delete links as objects in index
views so why when I google how to pass params to a delete link all the
answers are examples where a path is used My links don't have a path, they
have an object That's rails out of the box Like this:
<% @press_releases.each do |pr| %>
<tr>
<td><%= link_to 'Edit', edit_press_release_path(pr) %></td>
<td><%= link_to 'Delete', pr, method: :delete, data: { confirm:
'Are you sure?' } %></td>
I didn't write the above code, rails generated it I tried using
delete_press_release_path but there was no such route available So how do I
pass an additional parameter in this link please Thanks in advance
just press_release_path(additional_params: true)
The reason why that goes to the destroy action is because of method:
:delete
The rails scaffolding generator creates delete links as objects in index
views so why when I google how to pass params to a delete link all the
answers are examples where a path is used My links don't have a path, they
have an object That's rails out of the box Like this:
<% @press_releases.each do |pr| %>
<tr>
<td><%= link_to 'Edit', edit_press_release_path(pr) %></td>
<td><%= link_to 'Delete', pr, method: :delete, data: { confirm:
'Are you sure?' } %></td>
I didn't write the above code, rails generated it I tried using
delete_press_release_path but there was no such route available So how do I
pass an additional parameter in this link please Thanks in advance
just press_release_path(additional_params: true)
my bad. submitted immediately.
should be press_release_path(pr, additional_params: true)