SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante 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
 

Semelhante 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
 

Mais 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
 

Mais 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

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

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