Sha256: f7a119cd87a407979168b8e81df288eb0304431467c255cb7f7d5f76bb16de9c

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 Bytes

Contents

# We preload the models here, to let their component registration take effect
# on the routes builded by their categories later.

# TODO: to be discussed, how to handle this better.
# this active code can break applications, if their libraries depend on later initializers.
# after_initialization before routing would be the best.

Rails.configuration.after_initialize do
  model_path = Rails.root.join 'app/models'

  Dir.open(model_path).each do |file_handler|
    file_path = model_path.join(file_handler)
    require file_path if File.file?(file_path) && file_handler =~ /.*\.rb/
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
styleus-0.0.12 config/initializers/zz_preload_models.rb
styleus-0.0.11 config/initializers/zz_preload_models.rb