# Noob: how to pass parameters between pages in v2.0.2?

**URL:** <https://www.ruby-forum.com/t/noob-how-to-pass-parameters-between-pages-in-v2-0-2/130286>\
**Category:** Rails\
**Created:** [February 27, 2008, 3:11am UTC](https://www.ruby-forum.com/t/noob-how-to-pass-parameters-between-pages-in-v2-0-2/130286 "2008-02-27T03:11:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [February 27, 2008, 3:11am UTC](https://www.ruby-forum.com/t/noob-how-to-pass-parameters-between-pages-in-v2-0-2/130286/1 "2008-02-27T03:11:34Z")

</div>

Hey All,

I’m just starting out w/rails & have a toy app w/just 2 types of  
things right now: People and Organizations. Person :belongs\_to  
organization and Organization :has\_many people.

I’ve got scaffold-generated index views for both, which work well  
(thanks in part to the kind help I’ve already gotten here). The index  
page for organization shows the # of people that currently belong to  
each one, and I even got fancy and made that number a hyperlink to the  
people/index, w/view code like so:

 \<%= link\_to organization.people.count, "People", :action =\> :index %\>

Now I want to get even fancier, and have people/index show me _just_  
people belonging to the organization whose link was clicked. So I  
figured I’d need to pass the people controller the proper organization  
id, and have it do a proper Person.find() call.

I got the impression from the AWDWR book that I could just tack on an  
extra hash value on my link\_to call to pass the parameter, so I edited  
the above to say:

 \<%= link\_to organization.people.count, "People", :action =\> :index, :org\_id =\> organization.id %\>

And then put this in PeopleController.index:

```
if params[:org_id] then
  # raise("params[:org_id] IS defined!")
  @people = Person.find_by_organization(params[:org_id])
else
  @people = Person.find(:all)
end

```

But it seems that my parameter is _not_ getting passed. If I dump a  
params.inspect to the index page I see:

{“action”=\>“index”, “controller”=\>“people”}

Soooo… can anybody tell me the right way to move a parameter from  
one page to another?

Thanks!

-Roy

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [February 27, 2008, 7:37am UTC](https://www.ruby-forum.com/t/noob-how-to-pass-parameters-between-pages-in-v2-0-2/130286/2 "2008-02-27T07:37:04Z")

</div>

On 27 Feb 2008, at 02:10, Roy P. wrote:

> each one, and I even got fancy and made that number a hyperlink to the  
> people/index, w/view code like so:
> 
> \<%= link\_to organization.people.count, "People", :action =\> :index %\>

> =\> :index, :org\_id =\> organization.id %\>

Your problem here is that if you pass 2 parameters to link\_to like  
that, it’s going to assume that the first is some text and that the  
second is the url (or part of it)

> \<%= link\_to organization.people.count, :controller =\>  
> 'people", :action=\> :index, :org\_id =\> organization.id %\>  
> should do the trick.

Fred

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [February 27, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/noob-how-to-pass-parameters-between-pages-in-v2-0-2/130286/3 "2008-02-27T18:12:39Z")

</div>

Sure enough–that fixes it. Thanks!

On Feb 26, 10:36 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
