Merge pull request #3634 from TeBoring/ruby-bug

Cherry pick bug fix for ruby