Skip to content

Instantly share code, notes, and snippets.

@chrisbloom7
Created June 28, 2011 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbloom7/6e46c1b7c5b4d86e015c to your computer and use it in GitHub Desktop.
Save chrisbloom7/6e46c1b7c5b4d86e015c to your computer and use it in GitHub Desktop.
Method definition for news_archive_path
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