Why is the URL “id” element not part of the params objects after
submitting a form via form_tag?
Steps:
- Go to URL http://localhost:3000/users/delete?id=45
- Press Submit button
- Read id param in order to delete user, then redirect form
Delete Confirmation
<%= form_tag(‘/users/delete’) do %>
<%= submit_tag ‘Clique aqui para confirmar exclusão’ %>
<% end %>
def delete
if request.post?
if (!params[:id].nil?)
@user=User.find(params[:id])
@user.delete
end
redirect_to(:controller=>‘users’, :action => ‘list’)
end
end
When the form is posted, params[:id] does not exist, why?
Thanks