A
A
Alexander Petrov2016-02-28 23:20:38
Ruby on Rails
Alexander Petrov, 2016-02-28 23:20:38

How to find elements without empty field?

I need to exclude from the request all the data in which one field is filled.
For example: @section=Blog.where(blog_id: nil) so I can take all the articles that have an empty blog_id, but I need it the other way around so that they don’t get into the selection with an empty one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Yarikov, 2016-02-28
@Mirkom63

@section = Blog.where.not(blog_id: nil)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question