Friday, July 5, 2013

[Rails] Re: URL "id" not part of the params objects after post

Rodrigo Lueneberg wrote in post #1114538:
> Thanks Robert, You just gave some insight. You're right I should use
> form_for, but I just want to point that the user id is indeed passed in
> the URL above and I can reference a Model object even when not using a
> form_for. But I don't understand why it is not part of the
> "request" object querystring parameters? Any Framework should be able to
> capture both POST an URL parameters after a form submit action. How
> about environmental parameters such as referrer, etc.? I just doesn't
> make sense to me. I guess I will just keep reading more about rails.

> <%= form_tag('/users/delete') do %>
> <%= submit_tag 'Click here to delete this user' %>
> <% end %>

The form_tag helper defaults to a POST request if method is not
specified. Form fields will be pass in the request body not in the URL
query string. I don't see any indication that you're passing any form
data in your example above. It's not part of the URL and there are no
hidden fields that might contain any form data.

Example:
form_tag('/posts')
# => <form action="/posts" method="post">

Check your logs/development.log to see exactly what the params hash
contains for your request.

As for what you call "environmental parameters" I assume you mean
request headers. Request headers are available in the request object but
are not mixed into the params hash. That hash is reserved for user
submitted data (i.e. form fields and query parameters).

--
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/072527dac68e973ab16f0e670d0d7862%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


Real Estate