Rails Engines - what, why, how
Grzegorz Witek
Agenda
• What engines are
• How they appeared in Rails core
• How to use them
• What are their pros and cons
• Summary
What engines are
Application
Engine
Plugins
What are their capabilities?
Rails engines have:
Rack middleware stack
What are their capabilities?
Rails engines have:
environment.rb
What are their capabilities?
Rails engines have:
Routes
What are their capabilities?
Rails engines have:
Plugin support
Long way to the CORE
• Plugin
• Rails 2.3 - partial support
• 2010 Ruby Summer of Code
• Rails 3.1 - full engines in core
• ...
• 2011? - a few apps in the same process
A bit of code
Rails.application.routes.draw do mount Cms::Engine => "/portal", :as
=> 'cms' end
main_application.root_pathcms.articles_path
rake railties:copy_migrations
authenticate :admin do
mount Tolk::Engine => "/tolk" end
Are they really worth using?
Pros:
• they are almost as
powerful as rails app
• they are isolated (you don't
need to change your code
to use them!)
• You can share code
between applications
• they can save your time!
Cons:
• they're not suitable for
every application
Do they exist?
• Devise
• Rails Admin
• Rails Assets (to be released in 3.1)
• Tolk
Any questions?
Thanks for your attention!
Sources:
• http://piotrsarnacki.com
• https://github.com/dhh/tolk
• http://rails-engines.org/ 
• http://railscasts.com/episodes/149-rails-engines
• http://github.com/sferik/rails_admin
• https://github.com/lazyatom/engines
• https://github.com/rails/rails

Rails engines

  • 1.
    Rails Engines -what, why, how Grzegorz Witek
  • 2.
    Agenda • What enginesare • How they appeared in Rails core • How to use them • What are their pros and cons • Summary
  • 3.
  • 4.
    What are theircapabilities? Rails engines have: Rack middleware stack
  • 5.
    What are theircapabilities? Rails engines have: environment.rb
  • 6.
    What are theircapabilities? Rails engines have: Routes
  • 7.
    What are theircapabilities? Rails engines have: Plugin support
  • 8.
    Long way tothe CORE • Plugin • Rails 2.3 - partial support • 2010 Ruby Summer of Code • Rails 3.1 - full engines in core • ... • 2011? - a few apps in the same process
  • 9.
    A bit ofcode Rails.application.routes.draw do mount Cms::Engine => "/portal", :as => 'cms' end main_application.root_pathcms.articles_path rake railties:copy_migrations authenticate :admin do mount Tolk::Engine => "/tolk" end
  • 10.
    Are they reallyworth using? Pros: • they are almost as powerful as rails app • they are isolated (you don't need to change your code to use them!) • You can share code between applications • they can save your time! Cons: • they're not suitable for every application
  • 11.
    Do they exist? •Devise • Rails Admin • Rails Assets (to be released in 3.1) • Tolk
  • 12.
  • 13.
    Sources: • http://piotrsarnacki.com • https://github.com/dhh/tolk •http://rails-engines.org/  • http://railscasts.com/episodes/149-rails-engines • http://github.com/sferik/rails_admin • https://github.com/lazyatom/engines • https://github.com/rails/rails