Joined November 2012
·

Michel Billard

VarageSale
·
Montreal, Qc
·
·
·

Posted to Display date ranges in text in Rails over 1 year ago

@darkleaf nice work, I've actually implemented a gem myself, just forgot to mention it here: https://github.com/mbillard/time_will_tell

It also has a helper for another thing I do with datetimes regularly which is to display distances of time but precisely (ex: "3 hours 42 minutes" instead of "3 hours ago").

Posted to Display date ranges in text in Rails over 1 year ago

thanks @dopa, I've fixed the code.

Posted to Display date ranges in text in Rails over 1 year ago

Thanks @niuage, I've updated my answer with your recommendations and it does make it more readable.

What happens to mailto links, external links? Also, wouldn't it be better to tailor each link to only reload what's necessary instead of everything but the header and footer (although I guess you get most of the benefits by avoiding to reload the CSS and JavaScript everytime)?

@sandersch true, I never use Ruby alone so I don't always make the distinction between both.

I just use

["foo", "bar", ""].reject(&:blank?)

but I guess it won't work if the array contains items other than strings.

@rwz this will render only the partial (instead of your normal action). You can not include other arguments and I think there are other issues with that method, although I do not remember them (because that was what I first tried).