8. config/boot.rb
require 'rubygems'
!
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
!
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
10. COMMAND_WHITELIST = %(plugin server console … help)
def run_command!(command)
if COMMAND_WHITELIST.include?(command)
send(command)
else
write_error_message(command)
end
end
‘rails/commands/commands_tasks'
11. The happy scenario
def set_application_directory!
Dir.chdir(File.expand_path('../../', APP_PATH)) unless
File.exist?(File.expand_path("config.ru"))
end
def server
set_application_directory!
require_command!("server")
Rails::Server.new.tap do |server|
require APP_PATH
Dir.chdir(Rails.application.root)
server.start
end
end
def require_command!(command)
require "rails/commands/#{command}"
end
16. log_to_stdout
def log_to_stdout
wrapped_app # touch the app so the logger is set up
console = ActiveSupport::Logger.new($stdout)
console.formatter = Rails.logger.formatter
console.level = Rails.logger.level
Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
end
20. config/environment.rb
• This file initialises the application via
• Name::Application.initialize!
• This actually calls railties/lib/rails/application.rb
23. order of initialisers
• You can define order of run
• 01_something will be run before 02_something
24. middlewares
• At this point, the rails app itself is a middleware
• And now any written middle ware is called
• middleware written in config/initializers
• called via config/application.rb
25. routes
• The default routes are now loaded
• along with the custom routes in config/routes.rb
26. All files loaded
• At this point load order is done
• App servers like thin look for public directory to
load from unless routes overloads it and points
at other file.