SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 

Kürzlich hochgeladen (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 

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