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 7415485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:18:44+00:00 2026-05-29T07:18:44+00:00

I am new to Ruby on Rails and i am working through a few

  • 0

I am new to Ruby on Rails and i am working through a few example applications in the O’Reilly Head First Rails book. In one of the examples there is a page made up of three partials. The middle partial is a list of items. There is a link right below this section that, when clicked, should refresh the div containing that partial. The book is running examples based off of Rails 2.3 i believe and i am using Rails 3.1. This is the example that the book is giving me:

routes.rb:

map.connect '/flights/:flight_id/seats', :action=>'flight_seats', :controller=>'seats'

seats_controller.rb:

def flight_seats
    @flight = Flight.find(params[:flight_id])
    render :partial => "flights/seat_list", :locals => {:seats => @flight.seats}
end

show.html.erb:

<div id="seats">
    <%= render :partial=>"seat_list". :locals=>{:seats=>@flight.seats} %>
</div>

<$= link_to_remote("Refresh Seats", :url=>"/flights/#{@flight.id}/seats", method=>"get", :update=>"seats") %>

This example is also using prototype.js since that’s what Rails 2.3 came with built in. Rails 3 has jQuery as the default JavaScript library. (not sure if that makes a big difference)

Here is what i have so far. This is getting the contents of the partial correctly, it’s just not updating the “seats” div after the AJAX call gets the partial. My code:

routes.rb:

match 'flights/:flight_id/seats' => 'seats#flights_seats'

seats_controller.rb:

def flights_seats
    @flight = Flight.find(params[:flight_id])

    render :partial => "flights/seat_list", :locals => { :seats => @flight.seats }
end

show.html.erb:

<div id="seats">
    <%= render :partial => 'seat_list', :locals => { :seats => @flight.seats } %>
</div>

<%= link_to "Refresh Seats", "/flights/#{@flight.id}/seats", :remote => true %>

Any idea why my <div id="seats"> won’t refresh with the updated partial? I’m betting there is but i’ll ask anyway, is something wrong with my code?

  • 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-05-29T07:18:45+00:00Added an answer on May 29, 2026 at 7:18 am

    The :remote => true option is a bit weird if you aren’t returning JSON data. You can wrap your HTML in a JSON object, though, which is what I typically do. Or if you want something closer to your existing code something like this should work for you:

    <%= link_to "Refresh Seats", "/flights/#{@flight.id}/seats", :class => "refresh-seats" %>

    In your javascript somewhere:

    $(document).delegate(".refresh-seats", "click", function(e){
      e.preventDefault();
      $("#seats").load(this.href);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I'm quite new to ruby and rails... I have a little application working
I'm new to rails and working my way into the tutorial here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I've
I'm new to Ruby on Rails and am working my way through the tutorial
So right now I'm learning Ruby on Rails, and I'm working through the book
I am very new to ruby on rails.. working on my first project... am
New to both Ruby and Rails but I'm book educated by now (which apparently
i am working in Ruby on rails.. i am new to this.. i have
I'm really new at Ruby On Rails and I'm working with a baseApp that
I am new to Rails / Ruby. I am working on a project where
I'm working on learning ruby/rails at the moment - The book i'm reading has

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.