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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:25:32+00:00 2026-06-03T20:25:32+00:00

Right now I have some functionality working but its really ugly and I know

  • 0

Right now I have some functionality working but its really ugly and I know there’s a better way to do it.

Here’s what I have right now in my User model:

def attending
dayseventsusers=self.days_events_users
daysevents=Array.new
events=Array.new

dayseventsusers.each do |deu| 
  daysevents<<DaysEvent.find(deu['days_events_id'])
end

daysevents.each do |de|
  events<<Event.find(de['event_id'])
end

return events
end

I’m trying to get a list of events for a certain group of dayseventsusers records but I have to move through several relationships to accomplish this. What I’d really like to do is something like self.days_events_users.days_event.event, but I don’t know if it can be this simple assuming my relationships are setup correctly.

User model
has_many :days_events_users

DaysEventsUsers model
belongs_to :user
belongs_to :days_event

DaysEvent
has_many :days_events_users
belongs_to :event

The days_events_users object belong to a single days_event, which belongs to a single event. Any suggestions are welcome!

  • 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-03T20:25:33+00:00Added an answer on June 3, 2026 at 8:25 pm

    Without having tested this, does the following work:

    dayseventusers.collect(&:daysevent).collect(&:event)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have some troubles. I'm finding a way to solve one problem.
I have created some tests in my WPF application. Right now I am working
I have some code right now that executes when a link is clicked. The
My requirement is to work on some interface .h files. Right now I have
I have been writing some rspec tests, and right now I want to verify
Right now I have this SQL query which is valid but always times out:
Here is the situation: the company that I'm working in right now gave me
I'm working on a project right now where I have been slowly accumulating a
Wanted to get some consensus around a UI feature I'm working on right now.
Right now I have a jQuery plugin that adds some extra customization (around how

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.