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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:33:37+00:00 2026-06-13T20:33:37+00:00

Using Activerecord (on a postgresql database) this program should do a simple inner join

  • 0

Using Activerecord (on a postgresql database) this program should do a simple inner join between the tables “cars” and “car_parts”. Both tables exist in the db, are filled with data, and, keys are named by activerecord convention (i.e., primary keys in both tables are named “id”; foreign key in “car_parts” linking to “cars” is named “car_id”). I tried two alternatives by using “include” and “join” in Activerecord – unfortunately both failed with the below message. Any help appreciated, thanks! My program:

require 'active_record'

ActiveRecord::Base.establish_connection(
    # details left out
)

class Car < ActiveRecord::Base
  has_many :car_parts
end

class Car_Part < ActiveRecord::Base
  belongs_to :car
end

results2 = Car.joins(:car_parts)
results2.each{|row|  puts row.id}

results3 = Car.find :all, :include => [:car_parts]
results3.each{|row|  puts row.id}

For both results2 and results3 I receive the error message: “/home/myname/.rvm/gems/ruby-1.9.3-p194@global/gems/activerecord-3.2.8/lib/active_record/inheritance.rb:111:in `compute_type’: uninitialized constant Car::CarPart (NameError)”

  • 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-13T20:33:38+00:00Added an answer on June 13, 2026 at 8:33 pm

    You are mixing naming conventions. :car_parts refers to a class called CarPart whereas you are calling it Car_Part. Try to rename it to CarPart. (And embrace the next problem! 🙂 )

    Active record thinks that a camel case part of a word should translate to one underscore.

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

Sidebar

Related Questions

Using Rails ActiveRecord, am wanting to calculate the time between two datetime fields within
I'm using ActiveRecord / NHibernate for ORM mapping in my project with PostgreSQL 8.4.
In my Rails3 app, I am using ActiveRecord and Postgresql . Say I have
I have wrote a few simple Rails application, accessing the database via the ActiveRecord
I have a working postgresql database. My database.yml file is using postgresql for the
In Rails while using activeRecord why are join queries considered bad. For example Here
I am using ActiveRecord and when I call Model.Save which calls repositry.Update and then
Is there a way to create mysql triggers using Activerecord migrations ? Has anybody
Question: I really am trying to stick to using ActiveRecord and not using straight
Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion

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.