Closed thebravoman closed 5 years ago
I like the idea. My main concern is that if you send an object by accident, it will throw a confusing error like:
NoMethodError: undefined method `to_str' for #<User:0x00007fda326480e8>
What do you think about moving this change to cleanup_string
method, and also adding a validation? Like
def cleanup_string(string)
raise ArgumentError, 'Expected a string or an object that implements #to_str' unless string.respond_to?(:to_str)
strip_tags(string.to_str).gsub(/\s+/, ' ').strip.html_safe
end
Merged within https://github.com/kpumuk/meta-tags/pull/183
I have another object from another gem that is called @page_description and it is not a string. It is an active record. So could we call description.to_str and thus allow other objects to be passed.