I have this weird behavior of my helper and suspect is has something to do with Is Ruby pass by reference or by value?, can I ask for your help to explain the behavior?
views/xxx.html
helperA(@object.attribute_A)
helperA.rb
def helperA(object)
if object == nil
return
end
# do something if not nil
However when nothing is passed into the helper(object does not have attribute_A), the 'if object == nil' doesn't catch the situation and continue running the code, which usually will cause error like "undefined method `length' for nil:NilClass" that's because of the later operation in helper.
My question is why is this happening?