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

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -