I have a 3rd party gem with extension for String class:
class String
def to_url
self.gsub /\s+/, '-'
end
end
And I have my app trying to extend String class:
class String
def to_url
Russian.translit self
super
end
end
How do I call super (to replace spaces AND do transliteration) from my app? My code does super, but skips Russian.translit self.
There is no super to call. You should use alias_method
class String
alias_method :old_to_url, :to_url
def to_url
Russian.translit(self).old_to_url
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With