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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:54:44+00:00 2026-05-30T12:54:44+00:00

I have 3 models set up like this: Trip has_many :workgroups, through: :invitations Workgroup

  • 0

I have 3 models set up like this:

Trip
  has_many :workgroups, through: :invitations

Workgroup
  has_many :trips, through: :invitations
  has_many :employees

Employee
  belongs_to :workgroup

Employees are nested in workgroups.

I am trying to access employee data in the trip views. Currently, I get the following error: undefined method 'employees'

Can I access the employee data from the trip model without creating a direct association between the two models?

  • 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-30T12:54:46+00:00Added an answer on May 30, 2026 at 12:54 pm

    There is no way to directly reference the employee data from the trip model without creating an association.

    You can either add a has_many through relationship, or reference it something like this (I’m just making a guess based on your code above.)

    trip.workgroups.first.employees

    If you want to be able to view all ‘students’ associated in a workgroup that is associated to a trip, you’ll have to add the association.

    I think that you should be able to do this:

    Employee
      has_many :trips, through: workgroup
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two models set up like this: class User < ActiveRecord::Base #
I have a couple of Django models set up like this: class Group(models.model): name
I'm using Devise and have models set up like this: User has_one :profile Profile
I have three models, Event, Address and County, that are set up like this.
I have the models set up like this: class ParentModel(models.Model): some_col = models.IntegerField() some_other
I have two models ForumThread and Post set-up like this: class ForumThread < ActiveRecord::Cached
I have the following models set up: class Contact < ActiveRecord::Base belongs_to :band belongs_to
I've got some models set up like this: class AppGroup(models.Model): users = models.ManyToManyField(User) class
Say I have a three models that look (basically) like this: class User <
I have a model that looks like this class RSVP (models.Model): def __unicode__(self): return

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.