Rails Initialization process
require_frameworks
load_paths ( app/controller; app/models...)
load_environment
load_plugins
load_observers
after_initialize
How to reload plugins on development env:
add below code to environment.rb file:
Rails::Initializer.run do |config| #... config.reload_plugins = true if RAILS_ENV == 'development' end
Exclude a plugin from auto-reloading:
add the follow init.rb
ActiveSupport::Dependencies.load_once_paths << lib_path
How to load a model file under models/subdirectory?
add below code to environment.rb file:
Rails::Initializer.run do |config| #... config.load_paths += %W( #{RAILS_ROOT}/app/models/subdirectory ) end
specify plugins loading order:
add below code to environment.rb file:
Rails::Initializer.run do |config| #... config.plugins = [ :will_paginate, :all, :respec ] end
Post new comment