This file contains hidden or 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
# This really should belong in String, not Date... | |
class String | |
# Calculate the Time represented by this string, and the (optional) time pattern | |
# that describes this string (see Time#strftime). | |
# Returns a nil time if the String does not match the pattern, or the pattern is invalid. | |
def strptime(format=nil) | |
date = format ? Date.strptime(self, format) : Date.strptime(self) | |
date.to_time | |
rescue |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
# Provide access to helper methods from outside controllers and views, | |
# such as in Presenter objects. Rails provides ActionController::Base.helpers, | |
# but this does not include any of our application helpers. | |
def self.all_helpers | |
@all_helpers_proxy ||= begin | |
# Start with just the rails helpers. This is the same method used | |
# by ActionController::Base.helpers | |
proxy = ActionView::Base.new.extend(_helpers) |