0

I have a model created with this migration:

create table :some_table do |t|
  t.string :list, array: true, default: []
end

I would like to find the record whose "list" array is empty. I tried with this:

SomeTable.where(list: [])

but it returns nil and I have records with the list emtpy.

3
  • 1
    try SomeTable.where(list: {}) Commented Dec 4, 2015 at 12:50
  • may you like to study more about it dockyard.com/blog/ruby/2012/09/18/… Commented Dec 4, 2015 at 12:51
  • 1
    Can you put this through an answer? I will give you karma then. Ah, and it's where(list: '{}') Commented Dec 4, 2015 at 13:13

1 Answer 1

1

Try:

SomeTable.where(list: '{}')

Reference list datatype

Sign up to request clarification or add additional context in comments.

Comments

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.