top domain questions



How to check whether a string contains a substring in rails


When programming in ruby on rails, we want to know how to check whether a string contains a substring.

string = "foobar"
substring = "foo"
if string.include? substring
   puts "String includes #{substring}"
end