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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

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

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

Mehr von Ismael G Marín C

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

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

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