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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:50:58+00:00 2026-05-26T22:50:58+00:00

I have a rails application with the following Models: User (id) Version (id, post_id,

  • 0

I have a rails application with the following Models:

User (id)
Version (id, post_id, creator_id)
Post (id)

So far setup is as follows:

User.rb:

has_many :versions

Version.rb:

belongs_to :creator, :class_name => "User"
belongs_to :post

Post.rb:

has_many :versions

Now i would like to link a user to the posts he has through the versions table, and to make it worst this connection must be called questions. I was thinking something like this:

Added to User.rb:

has_many :questions, :class_name => "Post", :source => :post, :through => :versions

Problem is this doesn’t work and probably shouldn’t since it doesn’t know what the user key’s name is in the versions table.

Error message:

SQLite3::SQLException: no such column: versions.user_id: SELECT COUNT(*) FROM “posts” INNER JOIN “versions” ON “posts”.”id” = “versions”.”post_id” WHERE “versions”.”user_id” = 1

I’m at a loss, help!

Note: The only relationship that doesn’t work is the final one users <==> posts a.k.a users.questions

  • 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-26T22:50:59+00:00Added an answer on May 26, 2026 at 10:50 pm

    This setup should work for you:

    user.rb

    has_many :versions, :foreign_key => 'creator_id'
    has_many :questions, :through => :versions
    

    version.rb

    belongs_to :creator, :class_name => "User"
    belongs_to :question, :class_name => "Post", :foreign_key => 'post_id'
    

    post.rb

    has_many :versions
    

    Now you can access the questions like so: User.first.questions

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

Sidebar

Related Questions

I have the following models in my Rails application: class Shift < ActiveRecord::Base has_many
I have two models/tables in my Rails application: discussions and comments. Each discussion has_many
I have a Rails 3.1.1 application with the following models: Company Member The two
I have a rails application where each user has a separate database. (taking Joel
In my rails application my models have a to_html method. This method is called
I have a Rails 2.3 application. I currently have the following validations in my
My rails application has two models, gallery and photo. Galleries have many photos and
I have a rails application which is still showing the cachebusting numeric string at
I have a rails application running on a Linux server. I would like to
I have a Rails application that in the erb code, I use a select

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.