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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:40:45+00:00 2026-05-31T13:40:45+00:00

Seems I’ve defined the source as the AR error message suggests, but still getting

  • 0

Seems I’ve defined the source as the AR error message suggests, but still getting errors. Any idea? Rails 3.2, Ruby 1.9.2

    class Document < ActiveRecord::Base
      has_many :participations
      has_many :users, :through => :participations

      has_many :editing_sessions
      has_many :editors, :through => :editing_sessions, :source => :users
    end


    class User < ActiveRecord::Base
      has_many :participations
      has_many :documents , :through => :participations

      has_many :editing_sessions
      has_many :open_documents, :through => :editing_sessions, :source => :documents
    end


    class EditingSession < ActiveRecord::Base
      belongs_to :users
      belongs_to :documents
    end

    create_table "editing_sessions", :force => true do |t|
      t.integer  "user_id"
      t.integer  "document_id"

      t.datetime "created_at",  :null => false
      t.datetime "updated_at",  :null => false
    end


    Console:

    u = User.first
    => ... OK

    u.editing_sessions
    => []

    u.open_documents
    => ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could not find the source association(s) :document in model EditingSession. Try 'has_many :open_documents, :through => :editing_sessions, :source => <name>'. Is it one of :users or :documents?
  • 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-31T13:40:46+00:00Added an answer on May 31, 2026 at 1:40 pm

    Try changing the EditingSession definition so that the belongs_to labels are in the singular form:

    class EditingSession < ActiveRecord::Base
      belongs_to :user
      belongs_to :document
    end
    

    But leave the other source definitions in the Document and Users classes in the plural form (i.e. :source => :users and :source => :documents)

    Thats the convention in the Ruby on Rails Has-Many-Through Guide

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

Sidebar

Related Questions

Seems like cuke doesn't show the full error message (at least when problem occurs
Seems like a simple enough question but I can't seem to find the answer.
Seems likes it might be useful to have the assert display a message when
Seems like as really simple thing to do, but I just can't track it
Seems simple but users have no internet access. The application will be hosted internally
Seems like this might be easy, but from reading other SO answers there are
Seems to be a fairly hit issue, but I've not yet been able to
Seems like this should be simple enough but for whatever reason I am unable
Seems like a basic question but I just can't figure it out: xcode 5.0
Seems like the problem with this is the PHP syntax, but no luck in

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.