sql - Getting an Array from Return statement, deduce a string from that -


i have 'case' conditional code snippet wherein returning 2 objects. psuedocode -

case name when 'a' object1 = - sql logic - when 'b' object1 = - sql logic - when 'c' object2 = - sql logic - when 'd' object2 = - sql logic -  end return object1, object2 

as evident, returning 2 objects. however, in controller need 1 object @ time. object returned in form of array ['value', 'nil']. 1 of them nil. in controller passing 1 of these objects -

model.find_by_sql ["select * #{object}"]  #either object1 or object2 

is there way can break off array , return object required @ place string?

thanks.

return [object1, object2].compact

you can use compact method remove nil value of array.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -