Ruby on Rails: How to pass parameters from view to controller with link_to without parameters showing up in URL?

There are two options that I can see and both involve JavaScript.

There are two options that I can see and both involve JavaScript: Have the link populate hidden form fields for the parameters and then submit the form using an HTTP POST request Have the link submit an AJAX request to the controller action (using an HTTP GET unless clicking the link changes server-side state, in which case a POST should be used) I think I would go with the second approach.

A POST can be used to move the parameters out of the URL and into the request, but this is not the "correct" or best practice. HTTP standards are such that non-GET requests are meant to be used only for requests that change state on the server. This is why you get a warning when you refresh a page that was generated in response to a POST.

There is nothing wrong with having parameters in the URL. So much focus should not be made on what appears to the URL bar, let alone what's after the?. If however you have some need (i.e.

Insistence of a client) to remove them, you have several options, two of which John mentions. I'm assuming your "new" action is REST-style, in that it's generating a form that would have to be submitted to change state on the server. Therefore your options might be: Use POST, even though it's not standard compliant.

Not recommended. Use AJAX GET. This requires javascript, and ajax handling does add requirements such as the use of a JS framework and testing.

Use GET (or POST), but capture the parameters and store them, the redirect the user back to another clean URL that displays those stored value. You could store those in the session hash, or create a database record of them. Actually you really should use POST in this case, since you are effectively changing state on the server by storing those parameters.In this case, if the user refreshes the page he is directed to, those parameters will be preserved.

This effectively removes the browser warning on refresh, something I can certainly appreciate.

Might be overkill but... >> author=ActiveSupport::Base64. Encode64("author=jim") => "YXV0aG9yPWppbQ==\n" >> ActiveSupport::Base64. Decode64(author) => "author=jim.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions