passing parameters to delete link_to

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

passing parameters to delete link_to

fugee ohu
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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/046f61e3-f8de-4adb-b33d-6fa39b519e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: passing parameters to delete link_to

Jim ruther Nill


On Wed, Jun 7, 2017 at 11:21 AM, fugee ohu <[hidden email]> wrote:
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  

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/046f61e3-f8de-4adb-b33d-6fa39b519e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-------------------------------------------------------------
visit my blog at http://jimlabs.herokuapp.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ8y7Ve88LGht5X6A8_okwPFG_CaK15uy34Bpuz6GeUBddpZ8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: passing parameters to delete link_to

Jim ruther Nill


On Wed, Jun 7, 2017 at 11:24 AM, Jim Ruther Nill <[hidden email]> wrote:


On Wed, Jun 7, 2017 at 11:21 AM, fugee ohu <[hidden email]> wrote:
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)
 

The reason why that goes to the destroy action is because of method: :delete  

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/046f61e3-f8de-4adb-b33d-6fa39b519e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-------------------------------------------------------------
visit my blog at http://jimlabs.herokuapp.com



--
-------------------------------------------------------------
visit my blog at http://jimlabs.herokuapp.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ8y7Vf2WHAADA4eeHP6vEwoD1ZsTJ%2B%2BphT1sUqiuuTt%3DjRBMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: passing parameters to delete link_to

fugee ohu
In reply to this post by fugee ohu


On Tuesday, June 6, 2017 at 11:21:44 PM UTC-4, fugee ohu wrote:
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

Thanks 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ea9aef75-0109-4be2-b72a-591617d3b9b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...