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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:44:37+00:00 2026-05-16T19:44:37+00:00

If I have two models. Model1 belongs_to Model2, and Model2 has_one Model1. Thus I

  • 0

If I have two models. Model1 belongs_to Model2, and Model2 has_one Model1. Thus I can access Model2 from Model1 as well as Model1 from Model2. Now my question is, can I change the relationship to Model2 belongs_to Model1 and Model1 has_one Model2? It also can let me traverse from Model1 to Model2 and from Model2 to Model1. I’m not sure of that, anyone can explain it please?

Thanks.

  • 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-16T19:44:37+00:00Added an answer on May 16, 2026 at 7:44 pm

    You can certainly change a relationship from one way round to the other.

    You’ll obviously need to add a model_1_id column on the model_two table, migrate any existing associations across and remove the model_2_id column on the model_one table.

    I can’t think of anything else you’d particularly need to do to get it to work. The associations behave pretty much identically when belongs_to is paired with has_one.

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

Sidebar

Related Questions

I have a simple has_one/belongs_to relationship between two models. This is a new association
I have two models Customer and Transaction Customer has_many :transactions Transaction belongs_to :customer Now
I have two models, Character and Background. Character has_one Background, and Background belongs_to Character.
I have two models, referral and user model. Referral belongs_to User AND user has_one
I have two models : Project has_one :abstract Abstract belongs_to :project After reading the
i have two models: class Category has many :jobs end class Job belongs_to :category
I have two models: class Subscription belongs_to :subscriber, :class_name => User belongs_to :subscribable, :polymorphic
Say I have two models and one belongs to another. Now normaly you would
I have two models: class User end class Message belongs_to :sender, :class_name=> 'User' belongs_to
I have a basic problem with a has_one and belongs_to association. I have two

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.