app/ directory. def engine? has_app_directory? end private def has_app_directory? File.directory?(File.join(directory, 'app')) end end end https://github.com/rails/rails/blob/2-3-stable/railties/lib/rails/plugin.rb
app/ directory. def engine? has_app_directory? end private def has_app_directory? File.directory?(File.join(directory, 'app')) end end end https://github.com/rails/rails/blob/2-3-stable/railties/lib/rails/plugin.rb # Engines are plugins with an app/ directory. def engine? has_app_directory? end private def has_app_directory? File.directory?(File.join(directory, 'app')) end
ActiveRecord::Base.instantiate_observers end end def initialize_database if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection end end end end https://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb
ActiveRecord::Base.instantiate_observers end end def initialize_database if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection end end end end https://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb if gems_dependencies_loaded && configuration.frameworks.include?(:active_record) ActiveRecord::Base.instantiate_observers end if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection end
:action_view, :action_mailer, :active_resource ] end end end https://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb def default_frameworks [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ] end
install_gem_spec_stubs set_load_path add_gem_load_paths require_frameworks set_autoload_paths add_plugin_load_paths load_environment preload_frameworks initialize_encoding initialize_database initialize_cache initialize_framework_caches initialize_logger initialize_framework_logging initialize_dependency_mechanism initialize_whiny_nils initialize_time_zone initialize_i18n initialize_framework_settings initialize_framework_views initialize_metal add_support_load_paths check_for_unbuilt_gems load_gems load_plugins https://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb # pick up any gems that plugins depend on add_gem_load_paths load_gems check_gem_dependencies # bail out if gems are missing - note that check_gem_dependencies # will have already called abort() unless $gems_rake_task is set return unless gems_dependencies_loaded load_application_initializers # the framework is now fully initialized after_initialize # Setup database middleware after initializers have run initialize_database_middleware # Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher # Routing must be initialized after plugins to allow the former to # extend the routes initialize_routing # Observers are loaded after plugins in case Observers or observed # models are modified by plugins. load_observers # Load view path cache load_view_paths # Load application classes load_application_classes # Disable dependency loading during request cycle disable_dependency_loading # Flag initialized Rails.initialized = true end end end
:alert ] initializer "responders.flash_responder" do |app| Responders::FlashResponder.flash_keys = app.config.responders.flash_keys # ... end end end https://github.com/plataformatec/responders/blob/v0.9.2/lib/responders.rb Responders
= false (development) # Roda toda vez antes de recarregar o ambiente. # cache_classes = true (production) # Roda antes da primeira requisição. } end end
instantiate_observers ActionDispatch::Reloader.to_prepare do ActiveRecord::Base.instantiate_observers end end end end end https://github.com/rails/rails/tree/3-2-stable/activerecord/lib/active_record/railtie.rb Active Record
observers" do config.after_initialize do ::Mongoid::instantiate_observers ActionDispatch::Reloader.to_prepare do ::Mongoid.instantiate_observers end end end end end end https://github.com/mongoid/mongoid/blob/3.0.0-stable/lib/mongoid/railtie.rb Mongoid
Haml.init_rails(binding) Haml::Template.options[:format] = :html5 end end end end https://github.com/indirect/haml-rails/blob/v0.3.5/lib/haml-rails.rb Haml
SimpleForm default files" source_root File.expand_path('../templates', __FILE__) def copy_config directory 'config' end def copy_scaffold_template # ... end end end end https://github.com/plataformatec/simple_form/blob/v2.0.2/lib/generators/simple_form/install_generator.rb SimpleForm
config.respond_to?(:app_generators) ? :app_generators : :generators end config.send(generator).orm :mongoid, migration: false end end end https://github.com/mongoid/mongoid/blob/3.0.0-stable/lib/mongoid/railtie.rb Mongoid
config.respond_to?(:app_generators) ? config.app_generators : config.generators generators.integration_tool :rspec generators.test_framework :rspec end end end https://github.com/rspec/rspec-rails/blob/v2.11.0/lib/rspec-rails.rb RSpec
:responders_controller else config.generators.scaffold_controller = :responders_controller end end end https://github.com/plataformatec/responders/blob/v0.9.2/lib/responders.rb Responders
>= 3.1 config.app_generators.template_engine :haml else config.generators.template_engine :haml end end end end https://github.com/indirect/haml-rails/blob/v0.3.5/lib/haml-rails.rb Haml
app.sandbox? require "active_record/railties/console_sandbox" end ActiveRecord::Base.logger = Logger.new(STDERR) end end end https://github.com/rails/rails/tree/3-2-stable/activerecord/lib/active_record/railtie.rb Active Record
do self.time_zone_aware_attributes = true self.default_timezone = :utc end end end end https://github.com/rails/rails/tree/3-2-stable/activerecord/lib/active_record/railtie.rb Active Record
Force routes to be loaded if we are doing any # eager load. config.before_eager_load { |app| app.reload_routes! } initializer "devise.url_helpers" do Devise.include_helpers(Devise::Controllers) end initializer "devise.omniauth" do |app| # ... end # ... end end https://github.com/plataformatec/devise/blob/v2.1.2/lib/devise/rails.rb Devise
cannot inherit from Rails::Plugin" end end end https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/plugin.rb def self.inherited(base) raise "You cannot inherit from Rails::Plugin" end
end => nil >> Rails.application => #<MyApp:0x007f99b98c8728 @initialized=false ... > >> class OtherApp < Rails::Application; end RuntimeError: You cannot have more than one Rails::Application
pkg directory rake install # Build and install rsonrails-0.0.1.gem into system gems rake release # Create tag v0.0.1 and build and push rsonrails-0.0.1.gem to Rubygems rake tasks