"There are stopped jobs" when I try to quit terminal
The reason that this happens is because there is a stopped job still open in that terminal window (duh!). Typically this happens when a program is run and suspended (with ctrlz).
To get a list of such jobs, use the command jobs
on the terminal and use fg
to revive each of those jobs and quit them properly. Once this is done, terminal can be exit
ed normally.
Of course, a simpler solution (not one that I would advise, though) would be to simply close the terminal with the mouse, ignoring any warning messages.
[source]
Related videos on Youtube
bo-oz
Updated on September 18, 2022Comments
-
bo-oz almost 2 years
I also posted a related question: https://stackoverflow.com/a/50613524?noredirect=1, which was more about this concept.
What I'm trying to do is the following: I want to find
Accounts
for which a certainUser
has created aReport
, or for which a user has adeadline
.scope :active_accounts_for_user, -> (user) { joins(:deadlines) .where(:deadlines => {user: [nil, user]}) .joins(:reports) .where(:reports => {user: user, day: (Date.today - 1.day..Date.today)}) }
Problem with this is that Rails created an AND query, so it will find only Accounts that both have a report and a deadline. That is obviously to restrictive for my usecase.
Edit: Ok, I found a solution, I'd like to confirm whether this is good practive though. I'm basically creating separate queries to both Models in order to fetch the account ID's, which I use in a simple where:
scope :active_accounts_for_user, -> (user) { accounts_with_reports = Report.where(user: user).where('date > ?', 24.hours.ago).pluck(:account_id) accounts_with_deadlines = Deadline.where(user: user).pluck(:account_id) account_ids = (accounts_with_reports + accounts_with_deadlines).compact return includes(:past_deadlines, :deadlines).where(id: account_ids) }
Is this a correct use of a scope?
-
stoneyang almost 10 yearsYou may want to read the following thread: serverfault.com/questions/240155/…
-
-
Jagdeep Singh about 6 yearsEven though the link you mentioned might solve the question, but it is more appropriate to include the relevant part of code here too. Otherwise, it could well be a comment on the question only.
-
bo-oz about 6 yearsThis only works in Rails 5 unfortunataly. Is there a Rails 4 equivalent?
-
maicher about 6 yearsIt was added in rails 5.0 github.com/rails/rails/blob/5-0-stable/activerecord/… Previous versions don't support or queries. The need to be written using pure SQL.
-
bo-oz about 6 yearsWon't Left Joins give me all the Accounts?
-
Phil about 6 yearsThe where clause should cover that by limiting the user and day range if a deadline is set. That said, you'll need to extend the conditions to exclude results where both deadline and report are NULL. I'll edit my answer to include a possibility for this.
-
bo-oz about 6 yearsThanks, great solution.
-
khiav reoy about 6 yearsYou could try rails_or which implements
or
method for Rails 3 and Rails 4