-
-
Save chrisbloom7/6e46c1b7c5b4d86e015c to your computer and use it in GitHub Desktop.
Method definition for news_archive_path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def news_archive_path(options = {}) | |
options.merge!(:controller => :news_articles, :action => :index) | |
year = options.delete :year; month = options.delete :month; day = options.delete :day | |
begin | |
t = Time.zone.local(year.to_i, month.nil? ? nil : month.to_i, day.nil? ? nil : day.to_i) | |
rescue | |
year, month, day = nil | |
end | |
if !year.nil? | |
options[:year] = t.year | |
if !month.nil? | |
options[:month] = t.month | |
if !day.nil? | |
options[:day] = t.day | |
end | |
end | |
end | |
url_for(options) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment