For instance, if I have a Time.now, how would I convert that to a friendly url string?
Time.now.some_method_here => some_url_friendly_string_here
I believe there is a built-in Ruby method to do so, but I can’t seem to locate it on Google. Any ideas?
As you’re using Rails (as indicated by your tag), you can use .to_s:
You can specify a time format to the method, which will format the string differently, such as
Time.now.to_s(:db). Please see this link for the default date formats. If you don’t specify a format, it’ll use the same as strftime.The next part of that page also describes how to add your own time formats, which is very simple: