I sure hope everyone had a wonderful Christmas with their families. I am personally enjoying taking a few days off work and doing some reading. On Christmas morning, I bought a copy of Rework (Kindle edition) by Jason Fried and David Heinemeier Hansson. The “Go” Chapter alone is worth the price of admission!
One day I may share more about this book. However, today it seems like a great time to share another Ruby on Rails coding trick with you. That is how to automatically have your web apps update their copyright notices.
With only a few days remaining until the end of 2011, copyright notice update day is coming soon. That is the day that many web masters tweak the content of their page footers to reflect the new year.
However, suppose you wanted to automate the update process in a website written in Ruby on Rails. Here is one way to do it with a simple layout helper function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
In layouts/application.html.erb (or your footer partial):
What is happening here?
The layout template calls copyright_notice_year_range, supplying the first year that the website was copyrighted as an integer. The helper returns the string that should be shown after the copyright symbol. Given the example above, on January 1, 2012, the notice will read:
© 2010 - 2012 YOUR COMPANY, INC. All Rights Reserved.
Be sure to replace the # with your company’s main website URL.
Here’s wishing everyone a happy and prosperous 2012!
Why year "2000", legal reason or rule?