activerecord - How to rewrite this rails 4 query to reduce the code -


I have a rail query where I am selecting all the test ID where the name field is empty or zero, rewrite it One way, then this is cleaner?

  Sue. Where (name: "") .pluck (: id) + test Where (name: zero) .pluck (: id) << Code>   

The shortest way I know Here's how to write it:

  Trial.Jet (name: [Nil, '']). ID  

This will find all the trials record IDs where name is empty or empty.TT produces the following SQL:

Where (`` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' >

Comments

Popular posts from this blog

python - Strange behavior using PyQt4's 'pyqtSlot' decorator before another decorator -

c# - UnhandledExceptionMode.ThrowException for AppDomain.UnhandledException -

c# - Process.Kill() returns access denied -