# Rendering a result from a different controller

**URL:** <https://www.ruby-forum.com/t/rendering-a-result-from-a-different-controller/178855>\
**Category:** Rails\
**Created:** [November 12, 2009, 11:03am UTC](https://www.ruby-forum.com/t/rendering-a-result-from-a-different-controller/178855 "2009-11-12T11:03:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![db\_333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/779978/32.png) [@db\_333](https://www.ruby-forum.com/u/db_333)\
**Post date:** [November 12, 2009, 11:03am UTC](https://www.ruby-forum.com/t/rendering-a-result-from-a-different-controller/178855/1 "2009-11-12T11:03:26Z")

</div>

Hi,

I am a bit new at rails, so I’m not sure how to approach this:

I have a view with a search box that calls a controller/model outside  
of the view. So the view I am working with is called ‘groups’ and I  
make a search to people, in another controller. I’d like the result  
of the search to get sent back to my view under groups.

Here’s what I have in the view:

show.erb:  
\<% form\_tag ({ :controller=\> ‘people’, :action=\> ‘index’}, :method=\>  
‘get’) do %\>

| **Name:** | \<%= text\_field\_tag :search\_name, params[:search\_name]%\> \<%= submit\_tag "Search", :name=\> nil %\> |

\<%end %\>

So instead of the result rendering in index under ‘people’, I’d like  
to get the array back and render a list of people in groups. I tried  
working with partials, but the issue is I need to get the array back  
into this view, so I can pass it to a partial.

My controller code in people looks like this (I put the logic in the  
model)

def people\_search  
@people\_tree\_searches = PeopleTreeV.search(params[:search\_name])  
end  
end

any pointers are appreciated

thanks

---

<div class="post-metadata">

**Author:** ![db\_333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/779978/32.png) [@db\_333](https://www.ruby-forum.com/u/db_333)\
**Post date:** [November 12, 2009, 11:44am UTC](https://www.ruby-forum.com/t/rendering-a-result-from-a-different-controller/178855/2 "2009-11-12T11:44:39Z")

</div>

Hi

```
 You can look at :collection This is likein your routes.rb you can 

```

add

map.resources :people, :collection =\> {:search =\> :any}

```
I am assuming map.resources :people is already there

```

Now you can have a method search in people controller and the  
corresponding view may/maynot in view/people

Sijo

---

<div class="post-metadata">

**Author:** ![db\_333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/779978/32.png) [@db\_333](https://www.ruby-forum.com/u/db_333)\
**Post date:** [November 13, 2009, 1:08am UTC](https://www.ruby-forum.com/t/rendering-a-result-from-a-different-controller/178855/3 "2009-11-13T01:08:10Z")

</div>

thanks, I will give this a try. Just out of curiosity, will I be able  
to add functionality to the partial?
