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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:10:42+00:00 2026-05-31T16:10:42+00:00

I am new to both DBs and Rails (using 3.2), and I suspect this

  • 0

I am new to both DBs and Rails (using 3.2), and I suspect this is a basic question that I’m just having trouble finding an answer for.

I’m making an app that tracks articles people submit to journals. So, each user has a number of articles. For each article, they can submit it to a number of journals. The submission object itself keeps track not only of the article being submitted and the journal it’s submitted to, but also the date it was submitted, the way it was submitted (email, online system, etc.), the date a response was received (if any), the response (if any) (e.g. accepted, resubmit, decline).

I’m trying to allow a user to view all of their outstanding submissions in one place. So, for each user, I’m trying to query the db to get all submissions belonging to articles that belong to that user, but only returning the submissions for which response is NULL (meaning there is no response yet, and thus the submission is still outstanding).

So my models are related like this:

class User < ActiveRecord::Base
  has_many :articles
end

class Article < ActiveRecord::Base
  belongs_to :user
  has_many :submissions
end

class Journal < ActiveRecord::Base
  has_many :submissions
end

class Submission < ActiveRecord::Base
  belongs_to :article
  has_one :journal
end

Now, for a given @user, I think I could do something like

@articles_with_subs = @user.articles.joins(:submissions)

and then

@out_subs = Array.new
@articles_with_subs.each do |article|
  outs = article.submissions.where("response NOT NULL")
  @out_subs.push outs
end
@out_subs.flatten!

but that seems pretty inefficient. What probably big, obvious thing am I missing?

Thanks very much.

  • 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-31T16:10:43+00:00Added an answer on May 31, 2026 at 4:10 pm
    @out_subs = Submission.where("response NOT NULL")
        .joins(:article).where(:article => {:user_id => @user.id})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new on both this site and ruby on rails! I have a common
I'm kinda new at both programming, and WPF. I know that this is pretty
I'm very new to both of these so please forgive my basic question. I
I'm relatively new to both C and bitwise operations and I'm having trouble with
I'm new to both Django and Python.. I just started using them a few
New to both Ruby and Rails but I'm book educated by now (which apparently
I have an application that (currently) needs to uses DBs served by both SQL
I am new to both Django and Rails. I am thinking of developing an
I'm new to both Pylons and AuthKit. I have basic authentication via AuthKit working
I am new to both WPF and WCF, and have a WPF app that

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.