# How to: Put multiple IDs into the params (when using a link)

**URL:** <https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681>\
**Category:** Rails\
**Created:** [December 1, 2009, 6:43pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681 "2009-12-01T18:43:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 1, 2009, 6:43pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/1 "2009-12-01T18:43:42Z")

</div>

Hi there,

I’m getting the error:

No route matches { :controller =\> “user/agentsubdomains”,  
:action =\> “destroy\_double”,  
:subdomain\_id =\> 7,  
:agent\_id =\> 11 }

Is it not possible to put as many “whatever\_ids” as I want in the params  
to use them in the controller? What would I have to do where?

The link looks like this:

\<%= link\_to\_remote h(name), :url =\> { :controller =\>  
‘user/agentsubdomains’,  
:action =\> ‘destroy\_double’,  
:subdomain\_id =\> 7,  
:agent\_id =\> 11 },  
:method =\> ‘delete’ %\>

Thanks a lot for helping me out!  
Tom

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 1, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/2 "2009-12-01T19:02:08Z")

</div>

Tom Ha wrote:

> Hi there,
> 
> I’m getting the error:
> 
> No route matches { :controller =\> “user/agentsubdomains”,  
> :action =\> “destroy\_double”,  
> :subdomain\_id =\> 7,  
> :agent\_id =\> 11 }
> 
> Is it not possible to put as many “whatever\_ids” as I want in the params  
> to use them in the controller?

What exactly are you trying to do? And what does the relevant part of  
your routes file look like?

Best,  
–Â  
MarnenÂ Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 1, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/3 "2009-12-01T20:52:58Z")

</div>

I just need to assign values to

- params[:subdomain\_id] and
- params[:agent\_id]

which are in this case

- 7 and
- 11

…so I can access these values in the controller using the params.

And here’s the excerpt from routes.rb:

ActionController::Routing::Routes.draw do |map|

map.namespace :user do |user|  
user.resources :agentsubdomains, :member =\> { :destroy\_double =\>  
:delete }  
[…]  
end

map.resource :session  
[…]

map.root :controller =\> “root”, :action =\> “index”

map.connect ‘\*path’ , :controller =\> ‘four\_oh\_fours’  
end

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 1, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/4 "2009-12-01T21:18:48Z")

</div>

Tom Ha wrote:

> I just need to assign values to
> 
> - params[:subdomain\_id] and
> - params[:agent\_id]
> 
> which are in this case
> 
> - 7 and
> - 11

You can always put in extra parameters as you’re trying to do. That’s  
not the problem.

> …so I can access these values in the controller using the params.
> 
> And here’s the excerpt from routes.rb:
> 
> ActionController::Routing::Routes.draw do |map|
> 
> map.namespace :user do |user|  
> user.resources :agentsubdomains, :member =\> { :destroy\_double =\>  
> :delete }  
> […]  
> end

The problem lies here, I think. Either your controller name is invalid,  
or you need a user\_id. I’m not sure which, but between the routing docs  
and your tests, you should be able to figure it out.

> map.resource :session  
> […]
> 
> map.root :controller =\> “root”, :action =\> “index”
> 
> map.connect ‘\*path’ , :controller =\> ‘four\_oh\_fours’  
> end

Best,  
–Â  
MarnenÂ Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 2, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/5 "2009-12-02T15:02:56Z")

</div>

Thanks!

(Yes, it was the user\_id that it needed…)

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 2, 2009, 3:37pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/6 "2009-12-02T15:37:33Z")

</div>

PS: Actually _any_ id does the trick (even a constant ‘dummy’ integer).

It won’t be used, but the routing format apparently needs an id for the  
path to be composed completely.

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 2, 2009, 3:39pm UTC](https://www.ruby-forum.com/t/how-to-put-multiple-ids-into-the-params-when-using-a-link/179681/7 "2009-12-02T15:39:36Z")

</div>

Tom Ha wrote:

> PS: Actually _any_ id does the trick (even a constant ‘dummy’ integer).
> 
> It won’t be used, but the routing format apparently needs an id for the  
> path to be composed completely.

That’s usually the way nested resources work by default. If it’s not  
accurate for your use case, change your routes (perhaps you want  
namespaced controllers instead).

Best,  
–Â  
MarnenÂ Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
