Commit a355b30fbf5127518eebb6cb4b49047253d778cb
1 parent
bdf4ad3b
Exists in
master
update load way
Showing
2 changed files
with
16 additions
and
8 deletions
Show diff stats
lib/has_magic_fields.rb
1 | 1 | require "has_magic_fields/version" |
2 | 2 | require "has_magic_fields/extend" |
3 | 3 | |
4 | - | |
4 | +module HasMagicFields | |
5 | + class Engine < ::Rails::Engine | |
6 | + paths = Dir[File.dirname(__FILE__), '/app/models/**/'] | |
7 | + | |
8 | + if !Rails.env.development? | |
9 | + config.eager_load_paths += paths | |
10 | + end | |
11 | + end | |
12 | +end | |
5 | 13 | ... | ... |
lib/has_magic_fields/extend.rb
... | ... | @@ -111,14 +111,14 @@ module HasMagicFields |
111 | 111 | end |
112 | 112 | end |
113 | 113 | |
114 | - | |
115 | - %w{ models }.each do |dir| | |
116 | - path = File.join(File.dirname(__FILE__), '../app', dir) | |
117 | - $LOAD_PATH << path | |
118 | - ActiveSupport::Dependencies.autoload_paths << path | |
119 | - ActiveSupport::Dependencies.autoload_once_paths.delete(path) | |
114 | + if Rails.env.development? | |
115 | + %w{ models }.each do |dir| | |
116 | + path = File.join(File.dirname(__FILE__), '../app', dir) | |
117 | + $LOAD_PATH << path | |
118 | + ActiveSupport::Dependencies.autoload_paths << path | |
119 | + ActiveSupport::Dependencies.autoload_once_paths.delete(path) | |
120 | + end | |
120 | 121 | end |
121 | - | |
122 | 122 | end |
123 | 123 | end |
124 | 124 | ... | ... |