SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
The Rails
         Engine That
           Could?
Saturday, April 28, 2012
Hi!
        www.launchware.com
        on the InterTubes

                                    Hiring




                             dpickett
                           on Twitter

Saturday, April 28, 2012
What I Can Tell You
                            About Rails Engines
                           • A Brief History
                           • A Rails Engine In Rails 3.1
                           • Implementation Gotchas
                           • Deployment Gotchas With Heroku
                           • Conclusions
Saturday, April 28, 2012
Out With The Old...
    • Components in Rails
            Beta and Rails 1


    • Components
            removed in Rails 2




Saturday, April 28, 2012
...In With the New


                                   • Engines in Rails 3
                                   • Enginex as part of Rails 3.1



Saturday, April 28, 2012
Generating

                     rails generate plugin thomas --mountable




Saturday, April 28, 2012
Saturday, April 28, 2012
Saturday, April 28, 2012
Manage Dependencies
                         In Your Gemspec


     Shift Your Perspective


Saturday, April 28, 2012
Shifting Perspectives

                      • Think like an API designer
                      • Favor composition over inheritance
                      • Obey SOLID principles for more
                           maintainable code




Saturday, April 28, 2012
Maintain Perspective

                      • Do as you would normally:
                       • Write migrations
                       • Seed data
                       • Run rake tasks
                       • Run generators

Saturday, April 28, 2012
Gotchas




Saturday, April 28, 2012
Routes

                      • Routes are loaded where you mount
                           them
                      • Only one opportunity for placement
                      • No flexibility to divide up routes for
                           fine tuning priorities


Saturday, April 28, 2012
Namespacing
           • Namespace Your Engine - it will save you lots of
                    pain.
           • If you must in your consuming application, use
                    ActiveSupport’s require_dependency to override:
        require_dependency
          Thomas::Engine.root.join(“app/models/user”).to_s

        class User < ActiveRecord::Base
         #override the engine here
        end

Saturday, April 28, 2012
Routes

                      • Routes are loaded where you mount
                           them
                      • Only one opportunity for placement
                      • No flexibility to divide up routes for
                           fine tuning priorities


Saturday, April 28, 2012
Consumer::Application do
        Thomas::Routes::UserRoutes.draw(self)
        #custom routes here
        Thomas::Routes::ScheduleRoutes.draw(self)
      end

      module Thomas
        module Routes
          module UserRoutes
            def self.draw(map)
              map.instance_eval do
                resources :user...
              end
            end
          end
        end
      end
Saturday, April 28, 2012
Named Routes Helpers

                      • If you don’t namespace, I found these to be
                           incredibly problematic
                      • You must include helpers in your
                           application controller and in your request
                           specs/tests




Saturday, April 28, 2012
class ApplicationController < ActionController::Base
      include Thomas::Engine.routes.url_helpers
      include ActionDispatch::Routing::PolymorphicRoutes
    end




                           You’ll use these two lines a lot.

           Apply when you get an undefined *_path or *_url
                              method

Saturday, April 28, 2012
Saturday, April 28, 2012
Devise
                      • Wiring I18n load paths is deferred until the
                           app comes up, disallowing override ability




Saturday, April 28, 2012
class Thomas::Engine < Rails::Engine
            config.after_initialize do
              Rails.application.config.after_initialize do
                paths = I18n.load_path.delete_if do |p|
                  p =~ /devise-/
                end

                           #put devise’s default locales in its place
                           I18n.load_path = paths + I18n.load_path
                           I18n.reload!

            end
          end




Saturday, April 28, 2012
Inherited Resources
                             And Responders
                                Doesn’t Work
                             Drops Your Responder




Saturday, April 28, 2012
Saturday, April 28, 2012
Wrong Thomas...
                              ...Go B’s




Saturday, April 28, 2012
class ApplicationController < ActionController::Base
  def self.engine_inherit_resources
      inherit_resources
      self.responder = MobileResponder
    end
  end
end




Saturday, April 28, 2012
Deploying Private
                             Gems To Heroku
                      • Bundle with your github credentials in
                           plaintext
                      • Maintain your own gem server
                      • Write a rake task to vendor the gem and
                           commit when deploying
                      • NEW: http://www.gemfury.com/

Saturday, April 28, 2012
Overall, Engines Are
                                 Great
             • There’s still room for
                      improvement, but they’re
                      awesome once you get
                      going
             • They will challenge you as
                      a developer and as a Rails
                      Framework user


Saturday, April 28, 2012
Thanks!

                      • I’ll post slides @ www.launchware.com
                      • Chat me up on Twitter: @dpickett
                      • Chat me up on IRC: dpickett in #boston.rb
                      • We’re hiring!

Saturday, April 28, 2012

Más contenido relacionado

Similar a Engines Lightning Talk

Dallas GUG Lift Presentation
Dallas GUG Lift PresentationDallas GUG Lift Presentation
Dallas GUG Lift PresentationBrent Lemons
 
An Analytics Toolkit Tour
An Analytics Toolkit TourAn Analytics Toolkit Tour
An Analytics Toolkit TourRory Winston
 
Flexible heterogenous replication
Flexible heterogenous replicationFlexible heterogenous replication
Flexible heterogenous replicationJeff Mace
 
Moose Design Patterns
Moose Design PatternsMoose Design Patterns
Moose Design PatternsYnon Perek
 
Best Practices - Seeqnce - 23/24-02-2012
Best Practices - Seeqnce - 23/24-02-2012Best Practices - Seeqnce - 23/24-02-2012
Best Practices - Seeqnce - 23/24-02-2012Youssef Chaker
 
Ruby CI with Jenkins
Ruby CI with JenkinsRuby CI with Jenkins
Ruby CI with Jenkinscowboyd
 
Preventing Drupal Headaches: Content Type Checklist
Preventing Drupal Headaches: Content Type ChecklistPreventing Drupal Headaches: Content Type Checklist
Preventing Drupal Headaches: Content Type ChecklistAcquia
 
Introduction to Apache Pig
Introduction to Apache PigIntroduction to Apache Pig
Introduction to Apache PigTapan Avasthi
 
Rails Engine :: modularize you app
Rails Engine :: modularize you appRails Engine :: modularize you app
Rails Engine :: modularize you appMuntasim Ahmed
 
A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5SSW
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolvertboyt
 
Getting started with MySQL
Getting started with MySQLGetting started with MySQL
Getting started with MySQLJohn Ashmead
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer ToolboxYnon Perek
 
One code Web, iOS, Android
One code Web, iOS, AndroidOne code Web, iOS, Android
One code Web, iOS, AndroidArtem Marchenko
 
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012cwabbott
 

Similar a Engines Lightning Talk (20)

Dallas GUG Lift Presentation
Dallas GUG Lift PresentationDallas GUG Lift Presentation
Dallas GUG Lift Presentation
 
An Analytics Toolkit Tour
An Analytics Toolkit TourAn Analytics Toolkit Tour
An Analytics Toolkit Tour
 
Flexible heterogenous replication
Flexible heterogenous replicationFlexible heterogenous replication
Flexible heterogenous replication
 
Moose Design Patterns
Moose Design PatternsMoose Design Patterns
Moose Design Patterns
 
JRuby at Square
JRuby at SquareJRuby at Square
JRuby at Square
 
Best Practices - Seeqnce - 23/24-02-2012
Best Practices - Seeqnce - 23/24-02-2012Best Practices - Seeqnce - 23/24-02-2012
Best Practices - Seeqnce - 23/24-02-2012
 
Berlin.JS Meetup
Berlin.JS MeetupBerlin.JS Meetup
Berlin.JS Meetup
 
Ruby CI with Jenkins
Ruby CI with JenkinsRuby CI with Jenkins
Ruby CI with Jenkins
 
Preventing Drupal Headaches: Content Type Checklist
Preventing Drupal Headaches: Content Type ChecklistPreventing Drupal Headaches: Content Type Checklist
Preventing Drupal Headaches: Content Type Checklist
 
Introduction to Apache Pig
Introduction to Apache PigIntroduction to Apache Pig
Introduction to Apache Pig
 
Rails Engine :: modularize you app
Rails Engine :: modularize you appRails Engine :: modularize you app
Rails Engine :: modularize you app
 
A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5
 
Aegir
AegirAegir
Aegir
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
 
Getting started with MySQL
Getting started with MySQLGetting started with MySQL
Getting started with MySQL
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer Toolbox
 
One code Web, iOS, Android
One code Web, iOS, AndroidOne code Web, iOS, Android
One code Web, iOS, Android
 
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
 
Requirejs
RequirejsRequirejs
Requirejs
 

Más de Dan Pickett

Developing Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDeveloping Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDan Pickett
 
5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby GemsDan Pickett
 
Refinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownRefinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownDan Pickett
 
VCR Lightning Talk
VCR Lightning TalkVCR Lightning Talk
VCR Lightning TalkDan Pickett
 
A Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileA Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileDan Pickett
 
So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?Dan Pickett
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About CodeDan Pickett
 

Más de Dan Pickett (8)

Developing Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDeveloping Developers Through Apprenticeship
Developing Developers Through Apprenticeship
 
Intro to jquery
Intro to jqueryIntro to jquery
Intro to jquery
 
5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems
 
Refinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownRefinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS Showdown
 
VCR Lightning Talk
VCR Lightning TalkVCR Lightning Talk
VCR Lightning Talk
 
A Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileA Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery Mobile
 
So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About Code
 

Último

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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 RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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 WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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)wesley chun
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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)
 

Engines Lightning Talk

  • 1. The Rails Engine That Could? Saturday, April 28, 2012
  • 2. Hi! www.launchware.com on the InterTubes Hiring dpickett on Twitter Saturday, April 28, 2012
  • 3. What I Can Tell You About Rails Engines • A Brief History • A Rails Engine In Rails 3.1 • Implementation Gotchas • Deployment Gotchas With Heroku • Conclusions Saturday, April 28, 2012
  • 4. Out With The Old... • Components in Rails Beta and Rails 1 • Components removed in Rails 2 Saturday, April 28, 2012
  • 5. ...In With the New • Engines in Rails 3 • Enginex as part of Rails 3.1 Saturday, April 28, 2012
  • 6. Generating rails generate plugin thomas --mountable Saturday, April 28, 2012
  • 9. Manage Dependencies In Your Gemspec Shift Your Perspective Saturday, April 28, 2012
  • 10. Shifting Perspectives • Think like an API designer • Favor composition over inheritance • Obey SOLID principles for more maintainable code Saturday, April 28, 2012
  • 11. Maintain Perspective • Do as you would normally: • Write migrations • Seed data • Run rake tasks • Run generators Saturday, April 28, 2012
  • 13. Routes • Routes are loaded where you mount them • Only one opportunity for placement • No flexibility to divide up routes for fine tuning priorities Saturday, April 28, 2012
  • 14. Namespacing • Namespace Your Engine - it will save you lots of pain. • If you must in your consuming application, use ActiveSupport’s require_dependency to override: require_dependency Thomas::Engine.root.join(“app/models/user”).to_s class User < ActiveRecord::Base #override the engine here end Saturday, April 28, 2012
  • 15. Routes • Routes are loaded where you mount them • Only one opportunity for placement • No flexibility to divide up routes for fine tuning priorities Saturday, April 28, 2012
  • 16. Consumer::Application do Thomas::Routes::UserRoutes.draw(self) #custom routes here Thomas::Routes::ScheduleRoutes.draw(self) end module Thomas module Routes module UserRoutes def self.draw(map) map.instance_eval do resources :user... end end end end end Saturday, April 28, 2012
  • 17. Named Routes Helpers • If you don’t namespace, I found these to be incredibly problematic • You must include helpers in your application controller and in your request specs/tests Saturday, April 28, 2012
  • 18. class ApplicationController < ActionController::Base include Thomas::Engine.routes.url_helpers include ActionDispatch::Routing::PolymorphicRoutes end You’ll use these two lines a lot. Apply when you get an undefined *_path or *_url method Saturday, April 28, 2012
  • 20. Devise • Wiring I18n load paths is deferred until the app comes up, disallowing override ability Saturday, April 28, 2012
  • 21. class Thomas::Engine < Rails::Engine config.after_initialize do Rails.application.config.after_initialize do paths = I18n.load_path.delete_if do |p| p =~ /devise-/ end #put devise’s default locales in its place I18n.load_path = paths + I18n.load_path I18n.reload! end end Saturday, April 28, 2012
  • 22. Inherited Resources And Responders Doesn’t Work Drops Your Responder Saturday, April 28, 2012
  • 24. Wrong Thomas... ...Go B’s Saturday, April 28, 2012
  • 25. class ApplicationController < ActionController::Base def self.engine_inherit_resources inherit_resources self.responder = MobileResponder end end end Saturday, April 28, 2012
  • 26. Deploying Private Gems To Heroku • Bundle with your github credentials in plaintext • Maintain your own gem server • Write a rake task to vendor the gem and commit when deploying • NEW: http://www.gemfury.com/ Saturday, April 28, 2012
  • 27. Overall, Engines Are Great • There’s still room for improvement, but they’re awesome once you get going • They will challenge you as a developer and as a Rails Framework user Saturday, April 28, 2012
  • 28. Thanks! • I’ll post slides @ www.launchware.com • Chat me up on Twitter: @dpickett • Chat me up on IRC: dpickett in #boston.rb • We’re hiring! Saturday, April 28, 2012