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

  • Home
  • SEARCH
  • 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 6138171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:49:03+00:00 2026-05-23T17:49:03+00:00

In creating a ruby on rails / jquery app, there’s a part of a

  • 0

In creating a ruby on rails / jquery app, there’s a part of a page that is time-consuming to generate.

I want to change how the page is loaded so that most of the page loads right away, and a placeholder is reserved for the time-consuming part to load asynchronously, and be injected into the page with ajax / jquery when it is finished.

What I have now (simplified):

app/views/sample/show.html.erb:

<div id="theResult">
    <%= render :partial => 'calculate', :object => @org) %>
</div>

and the partial will use some parts @org to generate some content (hitting another external REST service).

app/views/sample/_calculate.html.erb

<%
    # code to take org and turn it into content
%>
<!--...html to display results here -->

I realize this is probably breaking proper MVC architecture rules since my partial seems to have too much logic, and would like to clean that up as well…

So I guess I have two questions in one: (1) how do I get this to work, and (2) how should I clean this up to follow good ruby/rails/mvc practices?

  • 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-23T17:49:04+00:00Added an answer on May 23, 2026 at 5:49 pm

    First put an empty, placeholder div in the main response

    <div id="pink-dancing-elephants"></div>
    

    and then add a little jQuery to the page

    $.ajax({
        url: "/elephants/dancing",
        cache: false,
        success: function(html){
          $("#pink-dancing-elephants").append(html);
        }
    });
    

    and have the action that responses to /elephants/dancing/pink return the blob of HTML that you want to have fill up the div. In the action that is invoked by the AJAX request, you’ll want to render with :layout => false to keep the returned blob of HTML from including the entire frame. E.g.

    # elephants_controller.rb
    def dancing
      @elephants = #whatever
      render :layout => false
    end
    

    This would render the template in views/elephants/dancing.html.erb.

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

Sidebar

Related Questions

I'm creating a Ruby on Rails app that consists of stories. Each story has
Are there special libraries or packages or frameworks for Ruby that help in creating
I have been creating a website with Ruby on Rails, and will be hosting
I'm creating a fast application with ruby on rails, and after doing a lot
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I am creating a website in Ruby on Rails. I have a controller action
I'm creating a Ruby on Rails application, and I'm trying to create/login/logout users. This
im trying to understand the process of creating tables in ruby-on-rails 3. i have
I want to learn Ruby on Rails and have set up a test environment.
A specific page for my ruby on rails website is slow. To figure out

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.