Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Railties @ GuruSC

Railties @ GuruSC

Carlos Antonio

September 18, 2010
Tweet

More Decks by Carlos Antonio

Other Decks in Programming

Transcript

  1. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br BSI NA UNIDAVI - RIO DO

    SUL GP NO SENAC - RIO DO SUL/ FLORIANÓPOLIS Sunday, November 6, 11
  2. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br Railties ? Hooks GENERATORS module FooBar

    class Railtie < Rails::Railtie config.generators.orm = :foo_bar end end Sunday, November 6, 11
  3. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br Railties ? Hooks RAKE TASKS module

    FooBar class Railtie < Rails::Railtie rake_tasks do load 'foo_bar/foo.rake' end end end Sunday, November 6, 11
  4. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br Railties ? Hooks INIT module FooBar

    class Railtie < Rails::Railtie # initialization hooks config.before_configuration {} config.before_eager_load {} config.before_initialize {} config.after_initialize {} config.to_prepare {} end end Sunday, November 6, 11
  5. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br Railties ? Hooks INIT module FooBar

    class Railtie < Rails::Railtie initializer 'foo_bar.do_whatever' do |app| puts "I'm initializing!" # load your stuff here end end end Sunday, November 6, 11
  6. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br E O QUE EU FAÇO COM

    ESSE NEGÓCIO DE FRAMEWORK LOADING? Sunday, November 6, 11
  7. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br Railties ? Hooks INIT module FooBar

    class Railtie < Rails::Railtie initializer 'foo_bar.do_whatever' do |app| ActiveSupport.on_load(:active_record) do include FooBar::ActiveRecordExtensions end end end end Sunday, November 6, 11
  8. Carlos Antonio @cantoniodasilva blog.plataformatec.com.br ? module Responders autoload :FlashResponder, 'responders/flash_responder'

    autoload :HttpCacheResponder, 'responders/http_cache_responder' autoload :CollectionResponder, 'responders/collection_responder' require 'responders/controller_method' class Railtie < ::Rails::Railtie config.responders = ActiveSupport::OrderedOptions.new config.generators.scaffold_controller = :responders_controller # Add load paths straight to I18n, so engines and application can overwrite it. require 'active_support/i18n' I18n.load_path << File.expand_path('../responders/locales/en.yml', __FILE__) initializer "responders.flash_responder" do |app| if app.config.responders.flash_keys Responders::FlashResponder.flash_keys = app.config.responders.flash_keys end end end end Sunday, November 6, 11