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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:50:35+00:00 2026-05-11T19:50:35+00:00

As much amazing info as is out there, it often seems to fall just

  • 0

As much amazing info as is out there, it often seems to fall just short of my demented requirements. That said, I’m looking for a mechanism by which to handle multiple nested models on a single page.

Now, I’ve seen all the videos and posts (not really, but humor me) on nesting two models (Railscasts, etc.). However, I need to deal with models nested 4 deep, all the while using Javascript to keep the page clean.

Basically I have Site -> Buildings -> Controllers -> Measurements and would like to manage (CRUD) a complete site on a single page. I’m sure it’s possible, but I have yet to see a reasonably clean method around which I can wrap my head. If anyone has any input, I’m all ears (or eyes as the case may be).

Thanks in advance.

  • 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-11T19:50:35+00:00Added an answer on May 11, 2026 at 7:50 pm

    Some skilled programmers recommend only nesting resources 1 level deep. Certainly your domain can be more complex, but you shouldn’t expose all of that complexity in a single view. If you really need to manage an entire Site on a single page, I recommend you use multiple forms and update the various displays via AJAX, rather than trying to do it all in one form. You’ll have better usability and cleaner code.

    EDITED

    Okay, here’s a sample view in HAML:

    %h1 Editing Site
    #site-form
      - form_for @site, :class => 'remote', :'data-update' => '#site-form' do |f|
        %p
          = f.label :name
          = f.text_field :name
        %p
          [All the other fields on your Site model]
        %p
          = f.submit "Save Site"
    
    
    %h2 
      Buildings for 
      = @site.name
    #buildings-forms
      - for building in @site.buildings
        %div{ :id => "building-#{building.id}" }
          - form_for building, :class => 'remote', :'data-update' => "#building-#{building.id}" do |f|
            %p
              = f.label :name
              = f.text_field :name
            %p
              [All other building fields]
            %p
              = f.submit "Save Building"    
          %h3 
            Controllers for
            = building.name
            - for cntroller in building.controllers
              %div{ :id => "controller-#{cntroller.id}"}
                - form_for cntroller, :class => 'remote', :'data-update' => "#controller-#{cntroller.id}" do |f|
                  %p
                    = f.label :name
                    = f.text_field :name
                  %p
                    [All other controller fields]
                  %p
                    = f.submit "Save Controller"
    

    And the next level, Measurements, will look pretty much the same.

    As far as getting the AJAX rocking, in jQuery you say:

    $( function() {
      $('form.remote').submit( function() {
        var submitted_form = this;
        $.post( this.action, $.serialize(this), function( data_returned, status, request ) {
          var updated_block = $( data_returned ).find( $(submitted_form).attr('data-update').html();
          $( $(submitted_form).attr('data-update') ).html( updated_block );
        } );
        return false;
      } );
    
    });
    

    This allows each form to post and updates its updateable block with a new version from the server once a post has occurred. You can get fancier and use the metadata plugin to store info on which block should be updated and other info about the request, but this is simple and allows you to see the configuration in your html. data-x attributes are a scheduled feature of HTML5, but we can go ahead and use them anyway.

    By creating a convention for your remote forms, it’s easy to make jQuery handle all your ajax posts with a small amount of code. You’ll probably want some fancier stuff, spinners, validations, etc. There’s room for that, but this will get you started with a single page interface.

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

Sidebar

Related Questions

After much reading it seems that, really, the only way to read a number
In vim, there is this amazing plugin called command-t, that lets you fuzzy-search through
There's a database engine that looks amazing for a free tool and that is
I have a webfont that looks amazing on Firefox, not so much on Chrome.
https://www.readability.com/ is really amazing. I'm building a web app with content that I'd like
I just started today looking into Groovy. I consider using it to replace some
IS there a way to post a $var to $PHP_SELF so that I can
It's amazing how even the littlest program can cause so much trouble in C.
Hey, not exactly looking for code help as it's too much to ask for
Is there any calculation engine for C# that can automatically recalculate dependent fields when

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.