title: Rails and ajax - passing values to partial view
body: <p>Rails 3.2.3</p>
  
  <p>I need to insert many rows for a table by clicking a link using AJAX. It's working perfect but there is an issue. When I pass the value <code>@paged_photo</code>  to partial it's null there. However it's definitely not null, it contains a data.</p>
  
  <p><strong>#home/index.html.erb</strong></p>
  
  <pre><code>&lt;table   id="photos_table"&gt;
    &lt;%= render :partial =&gt; 'test_partial'  %&gt;
  &lt;/table&gt;
    &lt;%= link_to "More photos",  {:controller =&gt; "home", :action =&gt; "test_method" }, :remote =&gt; true %&gt;
  </code></pre>
  
  <p><strong>#home/_test_partial.html.erb</strong>;
   <strong>#there are 3 td for each row</strong>
   <strong>#@paged_photos is null here for some reason</strong> </p>
  
  <pre><code>&lt;tr&gt;
  &lt;td&gt;
     &lt;%= link_to :controller =&gt; 'photos', :action =&gt; 'show', :id=&gt;@paged_photos[0].id do %&gt;
         &lt;%=image_tag(@paged_photos[0].source)%&gt;
     &lt;%end%&gt;
  &lt;/td&gt;
  &lt;td&gt;
     &lt;%= link_to :controller =&gt; 'photos', :action =&gt; 'show', :id=&gt;@paged_photos[1].source do %&gt;
         &lt;%=image_tag(@paged_photos[1].source)%&gt;
     &lt;%end%&gt;
  &lt;/td&gt;
  &lt;td&gt;
     &lt;%= link_to :controller =&gt; 'photos', :action =&gt; 'show', :id=&gt;@paged_photos[2].id do %&gt;
         &lt;%=image_tag(@paged_photos[2].source)%&gt;
     &lt;%end%&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>#home/test_method.js.erb</strong></p>
  
  <pre><code>$('#photos_table').append('# &lt;%=j render :partial =&gt; 'test_partial'%&gt;');
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>   def test_method
          @paged_photos = get_photos        
          respond_to() do |format|
            format.js
          end
       end
  </code></pre>
  
  <p>How do I pass the value to partial to insert a row for a table?</p>