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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:10:28+00:00 2026-06-04T10:10:28+00:00

We recently upgraded our rails app from version 3.0.3 to 3.1.0. The application runs

  • 0

We recently upgraded our rails app from version 3.0.3 to 3.1.0. The application runs successfully for the most part as it did before with one major exception. We have a many-to-many relationship between two models, SurveyDatum and SubGroup, joined via a model called SubGroupSurveyDatum. Here is the code for each:

class SurveyDatum < ActiveRecord::Base
  has_many :sub_group_survey_data
  has_many :sub_groups, :through => :sub_group_survey_data
end


class SubGroup < ActiveRecord::Base
  has_many :sub_group_survey_data
  has_many :survey_data, :through => :sub_group_survey_data
end

And as you might expect:

class SubGroupSurveyDatum < ActiveRecord::Base
  belongs_to :survey_datum
  belongs_to :sub_group
end

If I have a SurveyDatum object that I retrieved previously from the database (lets call it ‘sd’), and I invoke the sub_groups method (sd.sub_groups), this is the resulting sql query generated by active record:

SELECT `sub_groups`.* FROM `sub_groups` INNER JOIN `sub_group_survey_data` ON `sub_groups`.`id` = `sub_group_survey_data`.`sub_group_id` WHERE `sub_group_survey_data`.`survey_datum_id` IS NULL

The “IS NULL” part is obviously where the id of my survey data object is supposed to go, however active record fails to use it. The object does indeed have an id, since as mentioned it was persisted and retrieved from the database. This problem only cropped up after we moved to rails 3.1, so I assume there’s something I’ve not done properly in accordance with the new version, but I have no idea. Any ideas? Thank you in advance for your help!

  • 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-04T10:10:29+00:00Added an answer on June 4, 2026 at 10:10 am

    We discovered the issue. I had forgotten that the survey_data table has a composite primary key. When we upped to version 3.2.3, and added in the SurveyDatum model the following:

    set_primary_key :id
    

    The query finally built and executed properly.

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

Sidebar

Related Questions

We just recently upgraded from Spring Security version 3.0 to version 3.1. Our old
We have recently upgraded from mvc2 to mvc3 and one of our Custom Authorization
We recently upgraded our app from Grails 1.3.7 to 2.1, which builds under maven,
I'm currently working with a rails 3.0.x app that's recently been upgraded from rails
We have recently upgraded our code base from a 2005 version to the latest
We've recently upgraded our Rails application. To be extra sure everything works, I've tried
We have recently upgraded one of our applications from Java 1.4 to Java 6.
We've recently upgraded one of our SSRS2005 servers to SSRS2008 and have found that
We just recently upgraded from VS2008 to VS2010. Our project compiles fine; but when
I've recently upgraded a page on our server from classic asp to asp.net The

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.