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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:06:30+00:00 2026-05-27T07:06:30+00:00

I have a nested association where I have Rubric > Indicator > Question. In

  • 0

I have a nested association where I have Rubric > Indicator > Question. In this gist you can see I step through the association correctly, then try to to clone the object and its associations. However, notice I have an empty array for klone.questions. I can do klone.indicators.first.questions and retrieve all questions associated with the first indicator, but I am looking for a way to retrieve all questions associated with a rubric (klone in this case).

https://gist.github.com/1389697

  • 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-27T07:06:30+00:00Added an answer on May 27, 2026 at 7:06 am

    Its looks like deep_clonable cannot handle has_many :through type associations. I ended up doing this by hand like this:

      def create
    template = Template.find params[:template][:id]
    params[:section_ids].each do |section|
      @rubric = Rubric.new(template.attributes.merge(:name => template.name))
      @rubric.section_id = section
      @rubric.save
      template.indicator_templates.each do |i|
        indicator = Indicator.new(:name => i.name, :rubric_id => @rubric.id)
        indicator.save
        i.question_templates.each do |q|
          question = Question.new(:name => q.name, :indicator_id => indicator.id)
          question.save
        end
      end
    end
    if @rubric.save
      redirect_to rubrics_path, :notice => "Successfully created rubric."
    else
      render :action => 'new'
    end
    end
    

    So for the 3 models I am trying to clone (Rubrics, Indicators and Questions) I created 3 other models that basically mimic these models. I called them Template (for Rubric), IndicatorTemplate(for Indicators) and QuestionTemplate(for Questions). Then I create a new Rubric, and step through the indicators and questions making the proper associations along the way.

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

Sidebar

Related Questions

I have a hierarchically nested associative array. It looks like this: A = {
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
I have a three-level multi-nested form in Rails. The setup is like this: Projects
I have a nested Form A Crew can have many meetings, a Meeting can
I have a model with a has_one and polymorphic association like this: class Disc
I'm trying to implement a Rails3 nested form with has-many through association. My model
How can I generate form fields for a has_many :through association that has additional
I have 3 models set up like this: Trip has_many :workgroups, through: :invitations Workgroup
I have nested dictionaries: {'key0': {'attrs': {'entity': 'p', 'hash': '34nj3h43b4n3', 'id': '4130'}, u'key1': {'attrs':
I have nested xsl:for loops: <xsl:for-each select=/Root/A> <xsl:for-each select=/Root/B> <!-- Code --> </xsl:for> </xsl:for>

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.