Permalink
Browse files

cleanup, removed dispensable `require` statements from `ActiveModel`

  • Loading branch information...
1 parent b7edbc7 commit 22598ee5992fc81d200b3aa99f18248a5259161a @senny senny committed Nov 25, 2012
View
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Removed dispensable `require` statements. Make sure to require `active_model` before requiring
+ individual parts of the framework.
+
+ *Yves Senn*
+
* Use BCrypt's MIN_COST in the test environment for speedier tests when using `has_secure_pasword`.
*Brian Cardarella + Jeremy Kemper + Trevor Turk*
@@ -1,5 +1,3 @@
-require 'active_support/callbacks'
-
module ActiveModel
# == Active \Model \Callbacks
#
@@ -1,5 +1,3 @@
-require 'active_support/inflector'
-
module ActiveModel
# == Active \Model Conversions
#
@@ -1,4 +1,3 @@
-require 'active_model/attribute_methods'
require 'active_support/hash_with_indifferent_access'
require 'active_support/core_ext/object/duplicable'
@@ -1,4 +1,3 @@
-require 'active_support/inflector'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/module/introspection'
@@ -5,7 +5,6 @@
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/object/try'
-require 'active_support/descendants_tracker'
module ActiveModel
# == Active \Model Observers Activation
@@ -1,9 +1,6 @@
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/except'
-require 'active_model/errors'
-require 'active_model/validations/callbacks'
-require 'active_model/validator'
darrenboyd
darrenboyd Feb 13, 2013

Later on the validations.rb file (at the end), the entire validations directory is required. These files assume their dependencies have already been required (i.e., they do little to no requiring of their own). However, they do depend on validator.rb.

If you require the following...

require 'active_model/naming'
require 'active_model/translation'
require 'active_model/validations'
require 'active_model/conversion'

It will work in OS X, but it will not work on Linux (possibly due to a sensitivity? I'm not sure why this happens).

If that block is changed to...

require 'active_model/naming'
require 'active_model/translation'
require 'active_model/validator' # fix broken Rails dependencies
require 'active_model/validations'
require 'active_model/conversion'

Then things work properly again.

Thoughts? Is this an issue with Rails code (I can fix, if you want)? Or, is this an issue with the above snippets?

senny
senny Feb 13, 2013 Owner

before fixing it, it would be nice if we knew why it works on OS-X and does not on Linux.

darrenboyd
darrenboyd Feb 13, 2013

It's because I'm an idiot ... although, to be fair, this is a bit of a weird problem...

The code I'm working on is a gem, and doesn't constrain itself to a specific minor version of active_model. So, the build environment (linux) was picking up 3.2.8, but the dev environment (os x) was picking up 3.2.12. And, this was fixed in that branch...

1f73a53

I'll update my gemspec appropriately. Sorry about the confusion, @senny and thanks for the attention!

senny
senny Feb 13, 2013 Owner

:) glad to hear that it works now.

module ActiveModel
@@ -1,5 +1,3 @@
-require 'active_support/callbacks'
-
module ActiveModel
module Validations
# == Active \Model Validation Callbacks

0 comments on commit 22598ee

Please sign in to comment.