# Templates and partials

**URL:** <https://www.ruby-forum.com/t/templates-and-partials/49279>\
**Category:** Rails\
**Created:** [December 2, 2005, 2:18am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279 "2005-12-02T02:18:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 2:18am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/1 "2005-12-02T02:18:12Z")

</div>

i´m having something like this:

\<%= render(:partial =\> ‘interview’, :object =\> @interviews)%\>

now, within the view, i´d like to pass the id-parameter to select a  
certain  
interview.  
like this (although this code is probably wrong):

\<%= render(:partial =\> ‘interview’, :object =\> @interviews, :id =\>  
1237)%\>

basically, i need the view to tell the controller which interview to  
choose.  
any idea how to achieve this?

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 2:26am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/2 "2005-12-02T02:26:17Z")

</div>

Use :locals:

\<%= render(:partial =\> ‘interview’, :locals =\> { :id =\> 1237 })%\>

Check the docs on ActionController::Base  
([Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000171))

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 2:42am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/3 "2005-12-02T02:42:27Z")

</div>

how can i access the id (local) within the controller to choose the  
right  
interview?

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 3:55am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/4 "2005-12-02T03:55:22Z")

</div>

What do you mean? You retrieve the right object from your controller  
and pass that object to your partial.

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 11:26am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/5 "2005-12-02T11:26:37Z")

</div>

As far as I understand:

First the controller is executed by rails  
Then the view is rendered  
And that’s it

So there will be no way to again execute the controller after  
the view has been rendered. This means, no communication from view to  
the controller is possible. Only from controller to view. And that’s how  
it  
should be. If the decision in the view depends on some user action I  
would  
suggest using Ajax. Otherwise I would rethink your problem and solve it  
in the controller where logic is supposed to be.

On Fri, 02 Dec 2005 11:12:13 +0100, patrick k  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 11:14am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/6 "2005-12-02T11:14:30Z")

</div>

as mentioned before:  
basically, i need the view to tell the controller which interview to  
choose.

well, maybe that´s not possible. maybe i need components.

---

<div class="post-metadata">

**Author:** ![patrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@patrick](https://www.ruby-forum.com/u/patrick)\
**Post date:** [December 2, 2005, 11:30am UTC](https://www.ruby-forum.com/t/templates-and-partials/49279/7 "2005-12-02T11:30:41Z")

</div>

i already thought it might (and should) be that way.  
guess i have to re-think my problem.

thanks for your answer.
