[Rails] Re: URL "id" not part of the params objects after post
Rodrigo Lueneberg wrote in post #1114532:
> <%= form_tag('/users/delete') do %>
> <%= submit_tag 'Click here to delete this user' %>
> <% end %>
>
> When the form is posted, params[:id] does not exist, why?
Because you're using for_tag instead of form_for:
<%= form_for :user, :method => :delete do |f| %>
Note: The above is just an example. Normally you would not use a form at
all to request that a given model be destroyed. Below is an proper
example of deleting a given user:
<%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you
sure?' } %>
Besides that I don't see how your form_tag would ever send anything
about the current user. It's not passing in the user, nor user id, at
all. It's just submitting to the /users/delete URL with no other
information.
--
Posted via http://www.ruby-forum.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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fe271ca6db3b1722518ebea78907023b%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home