# Www.address.com/data?number=1&number2&number3

**URL:** <https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427>\
**Category:** Rails\
**Created:** [November 24, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427 "2009-11-24T18:23:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 24, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/1 "2009-11-24T18:23:07Z")

</div>

Hi,

Any ideas how to get the the numbers from the url in the subject? That  
is sent as a POST but all the parameters have the same name. I can only  
get the last number of the params.

What’s the trick?

Thanks.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 24, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/2 "2009-11-24T18:24:19Z")

</div>

Sorry the request is:

[www.address.com/data?number=1&number=2&number=3](http://www.address.com/data?number=1&number=2&number=3)

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 25, 2009, 5:08am UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/3 "2009-11-25T05:08:59Z")

</div>

Hi

> . I can only get the last number of the params.

Yes that is true.You have to modify the view? Please paste the view  
code

Sijo

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 25, 2009, 9:30am UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/4 "2009-11-25T09:30:43Z")

</div>

Hi Sijo,

Not really doing anything with the view actually. I just need to get  
those in the controller and reply with some data back to the client.

This is part of a public spec that tells that a request like that should  
be sent to the server and the server should do something with it.

I know that if the request would be:  
[www.address.com/data?number[]=1&number[]=2&number[]=3](http://www.address.com/data?number%5B%5D=1&number%5B%5D=2&number%5B%5D=3)

Then I could easily get the values of the numbers, but that wouldn’t be  
following the spec and cause interoperability issues.

Any ideas how I could set a rule in routes.rb so I could interpret this  
problematic url?

Regards.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 25, 2009, 10:05am UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/5 "2009-11-25T10:05:06Z")

</div>

Hi

I think you have to look at Route Globbing in rails. It also deals  
with arrays.Please check this

> **[Rails: Route Globbing](http://blog.jayfields.com/2007/12/rails-route-globbing.html)**
>
> Today I was working with some code that utilized the same array on various pages. After evaluating a few options I decided that Rails Route ...

[http://api.rubyonrails.org/classes/ActionController/Routing.html](http://api.rubyonrails.org/classes/ActionController/Routing.html)

Sijo

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 25, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/6 "2009-11-25T15:07:29Z")

</div>

Thanks Sijo,

I actually found that by using any of these on the controller:

request.query\_string  
request.request\_uri  
request.url

I can get the whole clean request. So after some parsing I should be  
able to extract the params myself. A bit ugly but I can live with it at  
this point.

Thanks!

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 27, 2009, 11:42am UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/7 "2009-11-27T11:42:35Z")

</div>

comopasta Gr wrote:

> Hi,
> 
> Any ideas how to get the the numbers from the url in the subject? That  
> is sent as a POST but all the parameters have the same name. I can only  
> get the last number of the params.
> 
> What’s the trick?
> 
> Thanks.

Hi comopasta,

One simple solution is pass them as a comma separated string.

instead of

[www.address.com/data?number=1&number=2&number=3](http://www.address.com/data?number=1&number=2&number=3)

have it like this

[www.address.com/data?number=1,2,3](http://www.address.com/data?number=1,2,3)

and from the controller take it to an array

@numbers = params[:number].split(‘,’)

a quick and dirty solution 😃

cheers,  
sameera

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 27, 2009, 2:37pm UTC](https://www.ruby-forum.com/t/www-address-com-data-number-1-number2-number3/179427/8 "2009-11-27T14:37:37Z")

</div>

Hi,

Yeah that would be an option. The big problem is that there is a OMA  
spec that tells that the request SHALL come in the form of  
[www.address.com/data?number=1&number=2&number=3](http://www.address.com/data?number=1&number=2&number=3)

So that is the way how the request will come. It cannot be changed.  
In any case I solved the issue and can now get all the params and more  
🙂

Thanks!
