railties @ encontro guru sc (nao apresentado) - 2010.09.18

486 views
455 views

Published on

Railties presentation prepared for GuruSC meeting (not presented).

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
486
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

railties @ encontro guru sc (nao apresentado) - 2010.09.18

  1. 1. RAILTIES OU COMO DESENVOLVER PLUGINS/GEMS PARA RAILS Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  2. 2. $ WHOAMI Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  3. 3. CARLOS ANTONIO DA SILVA @cantoniodasilva Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  4. 4. BSI NA UNIDAVI - RIO DO SUL GP NO SENAC - RIO DO SUL/ FLORIANÓPOLIS Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  5. 5. TRABALHO NA Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  6. 6. DEVISE Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  7. 7. SIMPLE_FORM Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  8. 8. RESPONDERS Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  9. 9. Railties? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  10. 10. Railties? WTF??? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  11. 11. Initialization Application Railties Engine? Generators Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  12. 12. Initialization? HOOKS Application Railties Engine Generators Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  13. 13. Railties GENERATORS Hooks module FooBar class Railtie < Rails::Railtie config.generators.orm = :foo_bar? end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  14. 14. Railties RAKE TASKS Hooks module FooBar class Railtie < Rails::Railtie rake_tasks do load foo_bar/foo.rake? end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  15. 15. Railties INIT Hooks 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 Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  16. 16. Railties INIT Hooks module FooBar class Railtie < Rails::Railtie initializer foo_bar.do_whatever do |app| puts "Im initializing!"? # load your stuff here end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  17. 17. FRAMEWORK LOADING ActiveSupport.on_load(:active_record) do include FooBar::ActiveRecordExtensions end? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  18. 18. E O QUE EU FAÇO COM ESSE NEGÓCIO DE FRAMEWORK LOADING? Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  19. 19. Railties INIT Hooks 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 Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  20. 20. EXEMPLO REAL??? Carlos Antonio blog.plataformatec.com.br @cantoniodasilvaSunday, November 6, 11
  21. 21. 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 Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  22. 22. @cantoniodasilva ?! blog.plataformatec.com.br Obrigado !Sunday, November 6, 11

×