parameter values

Hi all,
i'm a bigginer in rails, i used before a j2ee
there was a method
      request.getParameterValues(param_name)
that return array of parameters values than have the same name

is there like that method in rails

Thanks
M.SH

What exactly do you mean 'the same name' ?

In Rails we have

request.path_parameters - the Hash of parameters generating a url actually, like :controller, :action, :host, :subdomain, :id or any other due to your routing settings. ex.: http://yoursite.com/articles/1 (:host => 'yoursite.com', :controller => 'articles', :action => 'show', :id => '1')

request.query_parameters - the Hash of additional parameters, it can be whatever. ex. :http://yoursite.com/articles&q="love" (:q => 'love')

combined accessor 'params' - the Hash of all parameters.

Since it Hash, there is no duplicate keys. Each key is uniq, but the values individual.

 request\.getParameterValues\(param\_name\)

that return array of parameters values than have the same name

What exactly do you mean 'the same name' ?

Exactly what he said -- the same name.

This: http://example.com/?foo=bar&foo=baz&foo=xyz

:: is a perfectly valid URL and easily processed in a Java web app.

combined accessor 'params' - the Hash of all parameters.

Since it Hash, there is no duplicate keys. Each key is uniq, but the values individual.

Yeah, I've never understood that choice.

Exactly what he said -- the same name.

This: http://example.com/?foo=bar&foo=baz&foo=xyz

Unacceptable :slight_smile:

Rails' approach: each key is unique.

If you want to get them grouped, just wrap them to array, and your params accessor will be like: {:foo => ['bar','bad','xyz']}

Yeah, I've never understood that choice.

Philosophy.

thank u for your reply,
i mean by name like

<form ..
  <input type="text" name="street">
  <input type="text" name="street">
  .
  .
</from>

i don't know the no. of elements <input>

Counter-philosophy --

  Be liberal in what you accept, and conservative in what you send.
     (Postel's Law)

Silently discarding data from a client is not, to my mind, a good thing.

To the OP: the answer is "no" :slight_smile:

use
<input type="text" name="street[]">
<input type="text" name="street[]">
and I think you will get them as an array in params[:street]

Colin

thanks for all
but Colin is the right answer for me
i have try it Colin ++ :slight_smile: