Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:35:30+00:00 2026-06-07T15:35:30+00:00

Rails 3.2.3 I need to insert many rows for a table by clicking a

  • 0

Rails 3.2.3

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 @paged_photo to partial it’s null there. However it’s definitely not null, it contains a data.

#home/index.html.erb

<table   id="photos_table">
  <%= render :partial => 'test_partial'  %>
</table>
  <%= link_to "More photos",  {:controller => "home", :action => "test_method" }, :remote => true %>

#home/_test_partial.html.erb;
#there are 3 td for each row
#@paged_photos is null here for some reason

<tr>
<td>
   <%= link_to :controller => 'photos', :action => 'show', :id=>@paged_photos[0].id do %>
       <%=image_tag(@paged_photos[0].source)%>
   <%end%>
</td>
<td>
   <%= link_to :controller => 'photos', :action => 'show', :id=>@paged_photos[1].source do %>
       <%=image_tag(@paged_photos[1].source)%>
   <%end%>
</td>
<td>
   <%= link_to :controller => 'photos', :action => 'show', :id=>@paged_photos[2].id do %>
       <%=image_tag(@paged_photos[2].source)%>
   <%end%>
</td>
</tr>

#home/test_method.js.erb

$('#photos_table').append('# <%=j render :partial => 'test_partial'%>');

controller

   def test_method
        @paged_photos = get_photos        
        respond_to() do |format|
          format.js
        end
     end

How do I pass the value to partial to insert a row for a table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:35:33+00:00Added an answer on June 7, 2026 at 3:35 pm

    Can you try to use the following in your home/test_method.js.erb?

    $('#photos_table').append('<%=j render :partial => 'test_partial', :paged_photos => @paged_photos %>');
    

    After this, access paged_photos in home/_test_partial.html.erb.

    If that works, you’ll have to modify your home/index.html.erb like this

    <%= render :partial => 'test_partial', :paged_photos => @paged_photos %>
    

    PS : I didn’t understand the use of # before <%=j in home/test_method.js.erb. Was it just a typo or it’s intentional?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML view in a rails app, and need to insert in
I working in Rails and I need to call to an PHP-script. I can
I am using Ruby on Rails and I need to store a search result
I'm using rails and need to show text, having 3 or more newline characters
On my local machine I develop my Rails application using MySQL, but on deployment
I'm using Rails and need to make reports about payments. I need to receive
[Rails] I need to run some code only 40% of the times, how may
Rails: I need to set a condition in a has_many that needs the self.id
My end goal is local development of a Radiant CMS installation. So, need rails
I need to install Rails 2.3.2 and Rails 2.3.4 simultaneously on my Ubuntu 9.04

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.