Last active
August 29, 2015 13:57
-
-
Save tlux/9598242 to your computer and use it in GitHub Desktop.
Rails: Implementation of Object#to_b to convert any value to Boolean in Rails (uses ActiveRecord Boolean Mappings)
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 Object | |
| def to_b | |
| self.in?(ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES) | |
| end | |
| alias_method :to_bool, :to_b | |
| end |
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 is an initializer to load all Core Extensions in your Rails App | |
| Dir[Rails.root.join('lib/core_ext/*.rb')].each do |file| | |
| require file | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment