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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:59:42+00:00 2026-05-25T10:59:42+00:00

Can you reference the properties of a join table in a has_many :through relationship?

  • 0

Can you reference the properties of a join table in a has_many :through relationship?

Classic join relationship:

class Committee
  has_many :positions
  has_many :members, through: :positions
end

class Member
  has_many :positions
end

class Positions
  belongs_to :committee
  belongs_to :member

  attr_accessible :description
end

This gives us a nice way to access members directly from the Committee:

c = Factory :committee
first_member = members.first

Accessing information on the join table via the association

Is there some way to reference the description of the position (which exists on the join table) from this relationship?

e.g.

first_member_description = members.first.proxy.description

If not then what’s the cleanest way to access the description of a particular committee member?

Why would I want to do this?

I want to do this because I want to find a committee member by name and then find their description:

i.e.

peters_description = committee.members.find_by_first_name('Peter').proxy.description
  • 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-25T10:59:42+00:00Added an answer on May 25, 2026 at 10:59 am

    You could add the finder on the Position class:

    class Position < ActiveRecord::Base
      belongs_to :committee
      belongs_to :member
    
      attr_accessible :description
    
      scope :find_all_by_first_name, lambda do |name|
        joins(:member).where("members.first_name = ?", name)
      end
    end
    

    This should allow you to do:

    peters_description = committee.positions.find_all_by_first_name('Peter').first.description
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using import aliasing in one file/class, we can reference class library namespaces by assigning
How can i reference a class property knowing only a string? class Foo {
Inside the CLLocation Class Reference under the properties section this what it says for
i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
In JSP I can reference a bean's property by using the tag ${object.property} Is
In Ruby you can reference variables inside strings and they are interpolated at runtime.
can some on help me on how i can reference images i have all
How do I create a resource that I can reference and use in various
The goal: To create a .NET dll i can reference from inside SQL Server
how can i reference a display object's coordinates according to it's parent object or

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.