require file in rails environment

There are different ways to load particular file in rails application environment if the required file exists. 1. Using RAILS_ROOT if File.exists?(file=File.join(RAILS_ROOT,’config’, ‘initializers’, ‘smtp_gmail.rb’)) require file end 2. Using Rails.root & join require Rails.root.join(‘config’, ‘initializers’, ‘smtp_gmail.rb’) 3. Using Rails.root, join & exists? method. if File.exists?(file = Rails.root.join(‘config’, ‘initializers’,’smtp_gmail.rb’)) require file end 4. Using File andContinue reading “require file in rails environment”