SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
Rails Engines
!
@igmarin
Rails Engines
• Engines are stand-alone Rails application that can
be mounted inside of another application
• Controllers and Models are defined within
modules of the engine’s namespace
• architecting an app with engines forces you to
really think through your dependencies and
makes you isolate things from the get go
Big Plus
• Reduce errors from duplication
• Reusable code
Generate Rails Engine
we have a rails new plugin generator that will help us
$ rails plugin new awesome
creates a skeleton for
developing any kind of Rails
extension with ability to run
tests using dummy Rails
application
awesome
|-- Gemfile
|-- Gemfile.lock
|-- MIT-LICENSE
|-- README.rdoc
|-- Rakefile
|-- awesome.gemspec
|-- lib
| |-- awesome
| | `-- version.rb
| |-- awesome.rb
| `-- tasks
| `-- awesome_tasks.rake
`-- test
|-- awesome_test.rb
|-- dummy
$ rails plugin new awesome --full
--full tells that we want an
engine including app:
• An app directory tree
• An a config/routes.rb
awesome
|-- Gemfile
|-- Gemfile.lock
|-- MIT-LICENSE
|-- README.rdoc
|-- Rakefile
|-- app
| |-- assets
| |-- controllers
| |-- helpers
| |-- mailers
| |-- models
| `-- views
|-- awesome.gemspec
|-- bin
| `-- rails
|-- config
| `-- routes.rb
|-- lib
| |-- awesome
| | |-- engine.rb
| | `-- version.rb
| |-- awesome.rb
| `-- tasks
| `-- awesome_tasks.rake
`-- test
|-- awesome_test.rb
|-- dummy
lib/awesome/engine.rb
module Awesome
class Engine < ::Rails::Engine
end
end
$ rails plugin new awesome --mountable
namespace-isolated engine.
Same as full
• Asset manifest files (application.js and
application.css)
• A namespaced ApplicationController stub
• A namespaced ApplicationHelper stub
• A layout view template for the engine
awesome
|-- Gemfile
|-- Gemfile.lock
|-- MIT-LICENSE
|-- README.rdoc
|-- Rakefile
|-- app
| |-- assets
| |-- controllers
| |-- helpers
| |-- mailers
| |-- models
| `-- views
|-- awesome.gemspec
|-- bin
| `-- rails
|-- config
| `-- routes.rb
|-- lib
| |-- awesome
| | |-- engine.rb
| | `-- version.rb
| |-- awesome.rb
| `-- tasks
| `-- awesome_tasks.rake
`-- test
|-- awesome_test.rb
|-- dummy
lib/awesome/engine.rb
module Awesome
class Engine < ::Rails::Engine
isolate_namespace Awesome
end
end
test/dummy/config/routes.rb
Rails.application.routes.draw do
mount Awesome::Engine => "/awesome"
end
Route Helpers
awesome.root_url # /awesome
!
main_app.root_url # /
Generators
lib/generators/awesome/install_generator.rb
!
module Awesome
class InstallGenerator < Rails::Generators::Base
def install
run ‘bundle install’
route “mount Awesome::Engine => ‘/awesome’”
rake ‘awesome:install:migrations’
rake ‘db:migrate’
end
end
end
Popular Engines
• Devise —> Authentication
• Spree —> e-Commerce
• Forem —> Forum
• RailsAdmin —> Admin Interface
• Monologue —> Blogging
Resources
• Great Book: Multitenancy on Rails by Ryan Bigg
• https://www.youtube.com/watch?v=s3NJ15Svq8U
• http://guides.rubyonrails.org/engines.html
• http://tech.taskrabbit.com/blog/2014/02/11/rails-4-
engines/
• http://gaslight.co/blog/maintainable-and-scalable-
systems-with-rails-engines

Contenu connexe

Tendances

Featfures of asp.net
Featfures of asp.netFeatfures of asp.net
Featfures of asp.netDivyaDev9
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails DeploymentAlan Hecht
 
Creating the application
Creating the applicationCreating the application
Creating the applicationJason Noble
 
Put a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going FastPut a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going FastOSCON Byrum
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETAlan Hecht
 
Orchestration service v2
Orchestration service v2Orchestration service v2
Orchestration service v2Raman Gupta
 
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10Jitendra Soni
 
Ec2 for Startups - Ian Eure
Ec2 for Startups - Ian EureEc2 for Startups - Ian Eure
Ec2 for Startups - Ian EureGeekWire
 
"Serverless" express
"Serverless" express"Serverless" express
"Serverless" expressAnna Gerber
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Codem_richardson
 
Ansible Automation for Oracle RMAN / Apex Restores
Ansible Automation for Oracle RMAN / Apex RestoresAnsible Automation for Oracle RMAN / Apex Restores
Ansible Automation for Oracle RMAN / Apex RestoresAbhilash Kumar
 
Sitecore sxa best practices and secrets 29th june 2021
Sitecore sxa best practices and secrets   29th june 2021Sitecore sxa best practices and secrets   29th june 2021
Sitecore sxa best practices and secrets 29th june 2021Jitendra Soni
 
Real Time with Rails 5
Real Time with Rails 5Real Time with Rails 5
Real Time with Rails 5Lucas Renan
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesRami Sayar
 
Empowering Publishers - Hosting Provider Selection Process - May-15-2013
Empowering Publishers - Hosting Provider Selection Process - May-15-2013Empowering Publishers - Hosting Provider Selection Process - May-15-2013
Empowering Publishers - Hosting Provider Selection Process - May-15-2013Amazon Web Services
 

Tendances (20)

Featfures of asp.net
Featfures of asp.netFeatfures of asp.net
Featfures of asp.net
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails Deployment
 
Creating the application
Creating the applicationCreating the application
Creating the application
 
October 2014 HUG : Apache Slider
October 2014 HUG : Apache SliderOctober 2014 HUG : Apache Slider
October 2014 HUG : Apache Slider
 
Reversengineering
ReversengineeringReversengineering
Reversengineering
 
Put a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going FastPut a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going Fast
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
 
Orchestration service v2
Orchestration service v2Orchestration service v2
Orchestration service v2
 
Presentation
PresentationPresentation
Presentation
 
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
 
Ec2 for Startups - Ian Eure
Ec2 for Startups - Ian EureEc2 for Startups - Ian Eure
Ec2 for Startups - Ian Eure
 
"Serverless" express
"Serverless" express"Serverless" express
"Serverless" express
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Code
 
Ember.js: Jump Start
Ember.js: Jump Start Ember.js: Jump Start
Ember.js: Jump Start
 
Ansible Automation for Oracle RMAN / Apex Restores
Ansible Automation for Oracle RMAN / Apex RestoresAnsible Automation for Oracle RMAN / Apex Restores
Ansible Automation for Oracle RMAN / Apex Restores
 
Sitecore sxa best practices and secrets 29th june 2021
Sitecore sxa best practices and secrets   29th june 2021Sitecore sxa best practices and secrets   29th june 2021
Sitecore sxa best practices and secrets 29th june 2021
 
Real Time with Rails 5
Real Time with Rails 5Real Time with Rails 5
Real Time with Rails 5
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive Images
 
Empowering Publishers - Hosting Provider Selection Process - May-15-2013
Empowering Publishers - Hosting Provider Selection Process - May-15-2013Empowering Publishers - Hosting Provider Selection Process - May-15-2013
Empowering Publishers - Hosting Provider Selection Process - May-15-2013
 
Ruby Setup
Ruby SetupRuby Setup
Ruby Setup
 

Similaire à Rails engines

Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails BasicsAmit Solanki
 
Rails Engine :: modularize you app
Rails Engine :: modularize you appRails Engine :: modularize you app
Rails Engine :: modularize you appMuntasim Ahmed
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Andy Maleh
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolvertboyt
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular applicationmirrec
 
Rails Engines - A presentation for the 22nd Athens Ruby Meetup
Rails Engines - A presentation for the 22nd Athens Ruby MeetupRails Engines - A presentation for the 22nd Athens Ruby Meetup
Rails Engines - A presentation for the 22nd Athens Ruby MeetupSkroutz S.A.
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsTom Z Zeng
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine PatternsAndy Maleh
 
Plug it on!... with railties
Plug it on!... with railtiesPlug it on!... with railties
Plug it on!... with railtiesrails.mx
 
How To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuHow To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuVEXXHOST Private Cloud
 
DevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time EngineDevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time EngineRonny Trommer
 
Hortonworks Technical Workshop: Apache Ambari
Hortonworks Technical Workshop:   Apache AmbariHortonworks Technical Workshop:   Apache Ambari
Hortonworks Technical Workshop: Apache AmbariHortonworks
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapMarcio Marinho
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 

Similaire à Rails engines (20)

Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Rails Engine :: modularize you app
Rails Engine :: modularize you appRails Engine :: modularize you app
Rails Engine :: modularize you app
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
 
Rails engine
Rails engineRails engine
Rails engine
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Rails engines
Rails enginesRails engines
Rails engines
 
Rails Engines
Rails EnginesRails Engines
Rails Engines
 
Rails Engines - A presentation for the 22nd Athens Ruby Meetup
Rails Engines - A presentation for the 22nd Athens Ruby MeetupRails Engines - A presentation for the 22nd Athens Ruby Meetup
Rails Engines - A presentation for the 22nd Athens Ruby Meetup
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
 
Aspose pdf
Aspose pdfAspose pdf
Aspose pdf
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Plug it on!... with railties
Plug it on!... with railtiesPlug it on!... with railties
Plug it on!... with railties
 
Rails::Engine
Rails::EngineRails::Engine
Rails::Engine
 
How To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuHow To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on Ubuntu
 
DevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time EngineDevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time Engine
 
Hortonworks Technical Workshop: Apache Ambari
Hortonworks Technical Workshop:   Apache AmbariHortonworks Technical Workshop:   Apache Ambari
Hortonworks Technical Workshop: Apache Ambari
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Rails engines
Rails enginesRails engines
Rails engines
 

Plus de Ismael G Marín C

Plus de Ismael G Marín C (7)

Domotica
DomoticaDomotica
Domotica
 
TDD with Ruby
TDD with RubyTDD with Ruby
TDD with Ruby
 
Rails Engine Español
Rails Engine EspañolRails Engine Español
Rails Engine Español
 
Panel Magmaconf
Panel MagmaconfPanel Magmaconf
Panel Magmaconf
 
Bootcamp Irapuato Welcome
Bootcamp Irapuato WelcomeBootcamp Irapuato Welcome
Bootcamp Irapuato Welcome
 
Rubymotion primeros pasos
Rubymotion primeros pasosRubymotion primeros pasos
Rubymotion primeros pasos
 
Presentacion minitest
Presentacion minitestPresentacion minitest
Presentacion minitest
 

Dernier

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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 FMESafe Software
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
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 DiscoveryTrustArc
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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
 
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 TerraformAndrey Devyatkin
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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 New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Rails engines

  • 2. Rails Engines • Engines are stand-alone Rails application that can be mounted inside of another application • Controllers and Models are defined within modules of the engine’s namespace • architecting an app with engines forces you to really think through your dependencies and makes you isolate things from the get go
  • 3. Big Plus • Reduce errors from duplication • Reusable code
  • 4. Generate Rails Engine we have a rails new plugin generator that will help us
  • 5. $ rails plugin new awesome creates a skeleton for developing any kind of Rails extension with ability to run tests using dummy Rails application awesome |-- Gemfile |-- Gemfile.lock |-- MIT-LICENSE |-- README.rdoc |-- Rakefile |-- awesome.gemspec |-- lib | |-- awesome | | `-- version.rb | |-- awesome.rb | `-- tasks | `-- awesome_tasks.rake `-- test |-- awesome_test.rb |-- dummy
  • 6. $ rails plugin new awesome --full --full tells that we want an engine including app: • An app directory tree • An a config/routes.rb awesome |-- Gemfile |-- Gemfile.lock |-- MIT-LICENSE |-- README.rdoc |-- Rakefile |-- app | |-- assets | |-- controllers | |-- helpers | |-- mailers | |-- models | `-- views |-- awesome.gemspec |-- bin | `-- rails |-- config | `-- routes.rb |-- lib | |-- awesome | | |-- engine.rb | | `-- version.rb | |-- awesome.rb | `-- tasks | `-- awesome_tasks.rake `-- test |-- awesome_test.rb |-- dummy
  • 8. $ rails plugin new awesome --mountable namespace-isolated engine. Same as full • Asset manifest files (application.js and application.css) • A namespaced ApplicationController stub • A namespaced ApplicationHelper stub • A layout view template for the engine awesome |-- Gemfile |-- Gemfile.lock |-- MIT-LICENSE |-- README.rdoc |-- Rakefile |-- app | |-- assets | |-- controllers | |-- helpers | |-- mailers | |-- models | `-- views |-- awesome.gemspec |-- bin | `-- rails |-- config | `-- routes.rb |-- lib | |-- awesome | | |-- engine.rb | | `-- version.rb | |-- awesome.rb | `-- tasks | `-- awesome_tasks.rake `-- test |-- awesome_test.rb |-- dummy
  • 9. lib/awesome/engine.rb module Awesome class Engine < ::Rails::Engine isolate_namespace Awesome end end test/dummy/config/routes.rb Rails.application.routes.draw do mount Awesome::Engine => "/awesome" end
  • 10. Route Helpers awesome.root_url # /awesome ! main_app.root_url # /
  • 11. Generators lib/generators/awesome/install_generator.rb ! module Awesome class InstallGenerator < Rails::Generators::Base def install run ‘bundle install’ route “mount Awesome::Engine => ‘/awesome’” rake ‘awesome:install:migrations’ rake ‘db:migrate’ end end end
  • 12. Popular Engines • Devise —> Authentication • Spree —> e-Commerce • Forem —> Forum • RailsAdmin —> Admin Interface • Monologue —> Blogging
  • 13. Resources • Great Book: Multitenancy on Rails by Ryan Bigg • https://www.youtube.com/watch?v=s3NJ15Svq8U • http://guides.rubyonrails.org/engines.html • http://tech.taskrabbit.com/blog/2014/02/11/rails-4- engines/ • http://gaslight.co/blog/maintainable-and-scalable- systems-with-rails-engines