How to make an SQL querey Within a partial, is that possilbe??

Hello,
I'm quite new to Rails and english is even not my first language, so
please excused nescience and clerical mistake.
I'll try to explain my problem as good as possible.

I try to implement a page where a profil is shown, this is searched by
ID.
within this profil page I want to include the comments that refer to
this profil.
In the back I have to database tabels, the one "profiles" and a second
"comments".
In the second one I ve the column "profil_id" because my Idea was to
search for the Id of the profil which is shown and than to display the
comments in which the profil_id is the same.

I already tried to implement this Idea but I hit some problems:

the profil page works fine.

show.erb.html:
                <tr>
      <td class="headline">Titel</td>
      <td>
        <div class="table-col">
          <%= h @profil.title %>
        </div>
      </td>
    </tr>
    <tr>
      <td class="headline"></td>
      <td>
        <div class="table-col">
          <%= h @profil.subtitle %>
        </div>
      </td>
    </tr>
    <tr>

             ......
             ......
             ....

            <div style="width: 500px; margin-top: 20px;">
    <h2>Kommentare</h2>
    <%= render :partial => "comments/
comments_show", :locals=>{:profil_id=>@profil.id} %>
  </div>

and there I tried to call a partial which display the comments...
And that my problem...
I hand over the profil_id (which works fine) but I ve NO idea how and
where to include the Search to find the comments with the same id...

in the file _comments_show.erb.html i ll tried something like that:

I JUST MISS THE END , sorry
Hello,
I'm quite new to Rails and english is even not my first language, so
please excused nescience and clerical mistake.
I'll try to explain my problem as good as possible.

I try to implement a page where a profil is shown, this is searched by
ID.
within this profil page I want to include the comments that refer to
this profil.
In the back I have to database tabels, the one "profiles" and a second
"comments".
In the second one I ve the column "profil_id" because my Idea was to
search for the Id of the profil which is shown and than to display the
comments in which the profil_id is the same.

I already tried to implement this Idea but I hit some problems:

the profil page works fine.

show.erb.html:
<tr>
<td class="headline">Titel</td>
<td>
<div class="table-col">
<%= h @profil.title %>
</div>
</td>
</tr>
<tr>
<td class="headline"></td>
<td>
<div class="table-col">
<%= h @profil.subtitle %>
</div>
</td>
</tr>
<tr>

         \.\.\.\.\.\.
         \.\.\.\.\.\.
         \.\.\.\.

        &lt;div style=&quot;width: 500px; margin\-top: 20px;&quot;&gt;
            &lt;h2&gt;Kommentare&lt;/h2&gt;
            &lt;%= render :partial =&gt; &quot;comments/

comments_show", :locals=>{:profil_id=>@profil.id} %>
</div>

and there I tried to call a partial which display the comments...
And that my problem...
I hand over the profil_id (which works fine) but I ve NO idea how and
where to include the Search to find the comments with the same id...

in the file _comments_show.erb.html i ll tried something like that:
   <%= h @comment.title %>
but that doesnt work.

Please help

You should have an association between profiles and comments (profile
has_one :comment or has_many :comments) and then profile.comment or
profile.comments will be the comment(s) you are looking for

Fred