SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
If you like go a bit more in depth,
      please read Piotr Sarnacki article:

http://piotrsarnacki.com/2010/06/18/rails-internals-railties/

   Anyhow, here is my slides for meetup.
Poke into Rails 3 railites


           Priit Tamboom
        priit@gitnation.com

             London
            13.09.2010
puts 'Hello!'



                  Early days...
              Not so early days...
                 Recent days...
...or just short shameless self presentation.
Presentation is about:

 Railtie and it's responsibilty
Engine and Application classes
          Initialization

   ...and one more thing ;-)
Credits and thanks goes to:


            Rails 3 source code
            Rails 3 edge guides
 José Valim and other Devise developers
 Piotr Sarnacki and his summer work/blog
          http://piotrsarnacki.com
Own experience during summer in Barcelona
What's the responsibility of Railites:



              Glues all together
     Handles all bootstrapping process
    Provides rails command line interface
       Provides rails generators core
What about class Railtie?
                railties/lib/rails/railtie.rb




  Class Railtie is the core of the Rails Framework
and provides several hooks to extend Rails and/or
         modify the initialization process.
Creating your own Railtie
# APP/Gemfile
gem 'my_gem'

# GEM/lib/my_gem.rb
requrie 'my_gem/railtie' if defined?(Rails)

# GEM/lib/my_gem/railtie.rb
module MyGem
 class Railtie < Rails::Railtie
 end
end
What about Engine class?




First, don't get confused with Engine plugin.
Rails 3 Engine class is quite different thing.
Engine is just subclass of Railtie



# railties/lib/rails/engine.rb
module Rails
 class Engine < Railtie
 end
end
Available paths in an Engine

class MyEngine < Rails::Engine
 paths.app                 = "app"
 paths.app.controllers     = "app/controllers"
 paths.app.helpers         = "app/helpers"
 paths.app.models          = "app/models"
 paths.app.views           = "app/views"
 paths.lib                 = "lib"
 paths.lib.tasks           = "lib/tasks"
 paths.config              = "config"
 paths.config.initializers = "config/initializers"
 paths.config.locales      = "config/locales"
 paths.config.routes       = "config/routes.rb"
end
Use middleware in initialization


# lib/my_gem/railtie.rb
class MyRailtie < Rails::Railtie
 initializer "my_railtie.initialization" do |app|
     app.middleware.use MyRailtie::Middleware
 end
end
One more thing :-)
What to expect from Rails 3.1?
What, not excited?
Anyhow, heavy lifting done by Piotr Sarnacki in
his time with Ruby Summer of Code.

At the moment treat his work as any other Rails
edge code, I'm sure he welcomes any feedback.
What to expect from Rails 3.1?


* Engine is now rack application
* Added middleware stack to Engine
* Engine can now load plugins
* Engine can load its own environment file
* Added helpers to call engines' route helpers
from application and vice versa
What to expect from Rails 3.1?

* Task for copying plugins' and engines'
migrations to application's db/migrate directory
* Changed ActionDispatch::Static to allow
handling multiple directories
* Added namespace() method to Engine, which
sets Engine as isolated
* Include all helpers from plugins and shared
engines in application
Good news




It looks Rails 3.1 will probably be very friendly for
             multible/mountable apps.
Bad news


 Please, don't go crazy with mountable apps,
             even with Rails 3.1

In my reality it's a pipe dream to create and use
        very high level dependencies.
However there is nish



Take a look how Devise works and what kind
     workflow/attitude José Valim has.
He has given a nice introduction about this topic in Barcelona,
     probably there will be something on online as well.
Thank you for you time!


Any questions or comments?


     Just in case, here is my profiles:
              Github.com/priit
              Twitter.com/priit
              http://priit.mx.ee
            priit@gitnation.com

Mais conteúdo relacionado

Semelhante a Railties

Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
Enrico Teotti
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
arif44
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summary
daniel.mattes
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
Vineet Chaturvedi
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 

Semelhante a Railties (20)

How to set up and test a Rails 3 Engine
How to set up and test a Rails 3 EngineHow to set up and test a Rails 3 Engine
How to set up and test a Rails 3 Engine
 
Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
 
Railties
RailtiesRailties
Railties
 
TorqueBox
TorqueBoxTorqueBox
TorqueBox
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
Plug it on!... with railties
Plug it on!... with railtiesPlug it on!... with railties
Plug it on!... with railties
 
RailsConf 2022 - Upgrading Rails: The Dual Boot Way
RailsConf 2022 - Upgrading Rails: The Dual Boot WayRailsConf 2022 - Upgrading Rails: The Dual Boot Way
RailsConf 2022 - Upgrading Rails: The Dual Boot Way
 
Viridians on Rails
Viridians on RailsViridians on Rails
Viridians on Rails
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summary
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
 
Sinatra Rack And Middleware
Sinatra Rack And MiddlewareSinatra Rack And Middleware
Sinatra Rack And Middleware
 
Rails engine
Rails engineRails engine
Rails engine
 
Rails engines
Rails enginesRails engines
Rails engines
 

Mais de Skills Matter

Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
Skills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
Skills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
Skills Matter
 

Mais de Skills Matter (20)

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Railties

  • 1. If you like go a bit more in depth, please read Piotr Sarnacki article: http://piotrsarnacki.com/2010/06/18/rails-internals-railties/ Anyhow, here is my slides for meetup.
  • 2. Poke into Rails 3 railites Priit Tamboom priit@gitnation.com London 13.09.2010
  • 3. puts 'Hello!' Early days... Not so early days... Recent days... ...or just short shameless self presentation.
  • 4. Presentation is about: Railtie and it's responsibilty Engine and Application classes Initialization ...and one more thing ;-)
  • 5. Credits and thanks goes to: Rails 3 source code Rails 3 edge guides José Valim and other Devise developers Piotr Sarnacki and his summer work/blog http://piotrsarnacki.com Own experience during summer in Barcelona
  • 6. What's the responsibility of Railites: Glues all together Handles all bootstrapping process Provides rails command line interface Provides rails generators core
  • 7. What about class Railtie? railties/lib/rails/railtie.rb Class Railtie is the core of the Rails Framework and provides several hooks to extend Rails and/or modify the initialization process.
  • 8. Creating your own Railtie # APP/Gemfile gem 'my_gem' # GEM/lib/my_gem.rb requrie 'my_gem/railtie' if defined?(Rails) # GEM/lib/my_gem/railtie.rb module MyGem class Railtie < Rails::Railtie end end
  • 9. What about Engine class? First, don't get confused with Engine plugin. Rails 3 Engine class is quite different thing.
  • 10. Engine is just subclass of Railtie # railties/lib/rails/engine.rb module Rails class Engine < Railtie end end
  • 11. Available paths in an Engine class MyEngine < Rails::Engine paths.app = "app" paths.app.controllers = "app/controllers" paths.app.helpers = "app/helpers" paths.app.models = "app/models" paths.app.views = "app/views" paths.lib = "lib" paths.lib.tasks = "lib/tasks" paths.config = "config" paths.config.initializers = "config/initializers" paths.config.locales = "config/locales" paths.config.routes = "config/routes.rb" end
  • 12. Use middleware in initialization # lib/my_gem/railtie.rb class MyRailtie < Rails::Railtie initializer "my_railtie.initialization" do |app| app.middleware.use MyRailtie::Middleware end end
  • 14. What to expect from Rails 3.1?
  • 16. Anyhow, heavy lifting done by Piotr Sarnacki in his time with Ruby Summer of Code. At the moment treat his work as any other Rails edge code, I'm sure he welcomes any feedback.
  • 17. What to expect from Rails 3.1? * Engine is now rack application * Added middleware stack to Engine * Engine can now load plugins * Engine can load its own environment file * Added helpers to call engines' route helpers from application and vice versa
  • 18. What to expect from Rails 3.1? * Task for copying plugins' and engines' migrations to application's db/migrate directory * Changed ActionDispatch::Static to allow handling multiple directories * Added namespace() method to Engine, which sets Engine as isolated * Include all helpers from plugins and shared engines in application
  • 19. Good news It looks Rails 3.1 will probably be very friendly for multible/mountable apps.
  • 20. Bad news Please, don't go crazy with mountable apps, even with Rails 3.1 In my reality it's a pipe dream to create and use very high level dependencies.
  • 21. However there is nish Take a look how Devise works and what kind workflow/attitude José Valim has. He has given a nice introduction about this topic in Barcelona, probably there will be something on online as well.
  • 22. Thank you for you time! Any questions or comments? Just in case, here is my profiles: Github.com/priit Twitter.com/priit http://priit.mx.ee priit@gitnation.com