I have a 'Case' conditional code snippet wherein I am returning two objects. The psuedocode is -
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, I am returning two objects. However, in my Controller I need one object at a time. The object are returned in form of Array like ['value', 'nil']. One of them is always nil. In my controller I am passing one of these objects as -
Model.find_by_sql ["select * from #{object}"] #either object1 or object2
Is there any way that I can break off this array and return the object that is required at that place as String?
Thanks.