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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:00:26+00:00 2026-06-05T04:00:26+00:00

I get the following error message when requesting the home page of my sample

  • 0

I get the following error message when requesting the home page of my sample app (following Michael Hartl’s Tutorial chapter 11):

“ActiveRecord::HasManyThroughSourceAssociationNotFoundError in Pages#home”
“Could not find the source association(s) :followed_id in model Relationship. Try ‘has_many :followed_users, :through => :relationships, :source => ‘. Is it one of :follower or :followed?”

This is really weird, since I followed the instructions of the tutorial exactly. I even copy pasted every single code fragment.

My user model (extract):

  class User < ActiveRecord::Base 

    has_many :relationships, foreign_key: "follower_id", dependent: :destroy
    has_many :followed_users, through: :relationships, source: "followed_id"

    has_many :reverse_relationships, foreign_key: "followed_id", class_name: "Relationship", dependent: :destroy
    has_many :followers, through: :reverse_relationships, source: :follower

My relationship model:

  class Relationship < ActiveRecord::Base
    attr_accessible :followed_id

    belongs_to :follower, class_name: "User"
    belongs_to :followed, class_name: "User"

    validates :follower_id, presence: true
    validates :followed_id, presence: true
  end

My migration file:

  class CreateRelationships < ActiveRecord::Migration
    def change
      create_table :relationships do |t|
        t.integer :follower_id
        t.integer :followed_id

        t.timestamps
      end

      add_index :relationships, :follower_id
      add_index :relationships, :followed_id
      add_index :relationships, [:follower_id, :followed_id], unique: true
    end
  end

I’ve been trying to fix this, but I simply don’t have any idea left what the problem might be (exact code copy from the tutorial).

  • 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-05T04:00:27+00:00Added an answer on June 5, 2026 at 4:00 am

    Found the error:
    In my user model I had to change

      has_many :followed_users, through: :relationships, source: "followed_id"  
    

    to

      has_many :followed_users, through: :relationships, source: :followed  
    

    Seems to be a typo in Hartl’s tutorial Listing 11.10 http://ruby.railstutorial.org/book/ruby-on-rails-tutorial#code:has_many_following_through_relationships, since that’s where I got the “source: “followed_id”” code from.

    I got the fixed code from Hartl’s github “sample app”.

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

Sidebar

Related Questions

Upon launching a sinatra app, I get the following error message: /home/matt/.rvm/gems/ruby-1.9.3-p125/gems/backports-2.5.1/lib/backports/tools.rb:310:in `require': cannot
I'm trying to start a rails app and get the following error message: C:\project\ruby\lyc>rails
I get the following error message when I try the following: Dim XL As
when I start GDB, I get the following error message in debugger: input:--- token
We get the following error when running at test: ContextSwitchDeadlock was detected Message: The
when trying to translate the confirmation message to Norwegian i get the following error:
I get the following error message when I try this query: $query .= ($tid,
I am running a Python code and I get the following error message: Exception
When creating a new object in PHP, I get the following error message: Fatal
When I call respondsToSelector in an ARC environment, I get the following error message

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.