# How to pass an Variable to an Partial?!?

**URL:** <https://www.ruby-forum.com/t/how-to-pass-an-variable-to-an-partial/189242>\
**Category:** Rails\
**Created:** [May 27, 2010, 12:37pm UTC](https://www.ruby-forum.com/t/how-to-pass-an-variable-to-an-partial/189242 "2010-05-27T12:37:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![happysmiley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@happysmiley](https://www.ruby-forum.com/u/happysmiley)\
**Post date:** [May 27, 2010, 12:37pm UTC](https://www.ruby-forum.com/t/how-to-pass-an-variable-to-an-partial/189242/1 "2010-05-27T12:37:41Z")

</div>

Hello,  
I’m new in Rails and I’m Trying to implement a plattform were  
authorized people can apply Profiles to a special topic.  
The profil can be identified by the ID and the title in the data  
base.  
So in the view/profil/show\_profil.html.erb the infomation of one  
Profil are perfektly shown.

My problem:  
I have an data base table called : “comment” in which I save comments  
users made to one Profil, identifed by the Profil ID which I also save  
in this table.  
My Idea was to invoke an partial in the View/profil/  
show\_profil.html.erb… something like:

```
      <%= render :partial => "comments/comments_show" %>

```

But how can I find and show the comments with the ID of the used  
Profil?!?!?  
Can I handover the Profil\_ID somehow and if so how can I use it?

It was hard for me to explain my problem and I hope this was  
understandable.  
Hope to get some Ideas and solutions.

---

<div class="post-metadata">

**Author:** ![happysmiley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@happysmiley](https://www.ruby-forum.com/u/happysmiley)\
**Post date:** [May 27, 2010, 12:48pm UTC](https://www.ruby-forum.com/t/how-to-pass-an-variable-to-an-partial/189242/2 "2010-05-27T12:48:13Z")

</div>

On 27 May 2010 11:20, happysmiley [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> users made to one Profil, identifed by the Profil ID which I also save  
> in this table.  
> My Idea was to invoke an partial in the View/profil/  
> show\_profil.html.erb… something like:
> 
> ```
> <%= render :partial => "comments/comments_show" %>
> 
> ```
> 
> But how can I find and show the comments with the ID of the used  
> Profil?!?!?  
> Can I handover the Profil\_ID somehow and if so how can I use it?

Have a look at the docs at  
[http://rails.rubyonrails.org/classes/ActionController/Base.html](http://rails.rubyonrails.org/classes/ActionController/Base.html) to see  
how to pass data to a partial. A google search for render partial  
puts this as the first hit.

Colin
