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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:49:45+00:00 2026-05-11T01:49:45+00:00

So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many)

  • 0

So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many) relationships in my application. I had one between models games and teams and another between models stats and results. This was all working just fine by creating the join table myself with a migration.

I then decided that I did not want to have the stats/results relationship be many-to-many but what to many instead so I ran the following migration and switched the relationships to has_many and belongs_to:

class FixingResultStatRelationship < ActiveRecord::Migration   def self.up     add_column :results, :stat_id, :integer     drop_table 'results_stats'   end    def self.down    remove_column :results, :stat_id    create_table 'results_stats', :id => false do |t|       t.column 'result_id', :integer       t.column 'stat_id', :integer     end     add_index 'results_stats', 'result_id'     add_index 'results_stats', 'stat_id'   end end 

Then when I do this it not only does the new one-to-many relationship not work as I get a NoMethodError when calling say Result.find(0).stat but now my previous working many-to-many relationship with games and teams is now broken as well. I used to be able to call Game.fine(0).teams just find and see the results and now I get a NoMethodError as well. Any thoughts? I am quite lost and any help would be great.

  • 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. 2026-05-11T01:49:46+00:00Added an answer on May 11, 2026 at 1:49 am

    I just realized that I had belongs_to :stats rather than the singular stat. I fixed this and reloaded the server and everything works fine now. Thanks anyways though Abie.

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

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer So I'm assuming we're really focusing on this set of… May 11, 2026 at 9:02 am
  • added an answer Since it is only 1 to 10, simply precompute it… May 11, 2026 at 9:02 am
  • added an answer Given you've tagged this as 'server-side' and talk about the… May 11, 2026 at 9:02 am

Related Questions

So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many)
I am just getting started with expression trees so I hope this makes sense.
I have just started to look at .NET 3.5 so please forgive me if
I am just getting started with IoC containers so apologies if this is a
So I started with a web services project (just a dynamic web project) that
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
Just getting started using MVC in ASP.NET, I'm going to have it so users
So I just fixed a bug in a framework I'm developing. The pseudo-pseudocode looks
So i just received a connection string to a Cube in our one of
Ok so I just did something boneheaded. I'm setting up a subversion server for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.