0

I working with Rails and Postgresql and I'm trying to query my postgres db based on the value of a column.

To put it into perspective, I have an Events table in postgres and in that table I have some events that are recurring and some that aren't based on the column value of repeats.

If the events recur, then they will have a value of daily, weekly, monthly, etc. inside of the repeats column. Obviously, if it doesn't recur then the value will be set to null.

I would like to receive only those events that recur in the repeats column. So if it's null, then the query will skip over it.

I've looked through the ActiveRecord Query Interface but due to my inexperience, I was unable to find a helper that would do the trick for me.

Please let me know if more info is needed.

Any advice will be greatly appreciated. Thanks!

1 Answer 1

1
Event.where.not(repeats: nil)

Alternatively, you can specify a sql stream

Event.where("repeats is not null")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much. Appreciate the help. @DVG

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.