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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:51+00:00 2026-05-25T19:38:51+00:00

I have a many-to-many relationship through a join table. This join table has an

  • 0

I have a many-to-many relationship through a join table. This join table has an additional field, an integer.

Now for filtering purposes, I want to add an attribute to one of the models reflecting the sum of this additional field for the associated entries.

I’ve tried stuff like:

has "SUM(<join_table_name.field_name>)", :as => :availability, :type => :int

But this just yields errors like “nil is not a symbol” when running rake ts:rebuild. I assume I’m just doing it wrong, so before I add a lot of unnecessary additional info, I thought I’d see if someone knows the correct way to do this?

  • 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-25T19:38:51+00:00Added an answer on May 25, 2026 at 7:38 pm

    I think you’re almost there – but first, it’s :integer, not :int – and secondly, if the join is not being referred to normally by any other fields or attributes, then you need to ensure it’s part of the query:

    join join_assoc
    

    Beyond that, it’s all looking fine.

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

Sidebar

Related Questions

I have a many-to-many relationship like this: A user has_many organizations through affiliations and
I have a table called transactions with a many-to-many relationship to items through the
I have a many-to-many relationship set up through a join model. Essentially, I allow
I have setup this HABTM relationship in the past and it has worked before....Now
I have a basic has_many :through relationship that is bi-directional: calendars have many calendar_calendar_events
When you have a many-to-many relationship ( related_name , not through ) and you
I have a many-to-many relationship with a link box, and I want to pull
I have a self join through an intersect table in an app I'm working
I have two tables (Rule and Object) linked through a many-to-many relationship. A Rule
UPDATED: to include model relationships I have a many to many join table between

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.