Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tirando Proveito das Rails Engines
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Nando Sousa
July 25, 2015
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tirando Proveito das Rails Engines
Nando Sousa
July 25, 2015
More Decks by Nando Sousa
See All by Nando Sousa
Metaprogramming in Elixir
nandosousafr
0
280
Yet another introduction to concurrency
nandosousafr
4
230
5 basic tips for RubyOnRails projects
nandosousafr
1
460
Robust search with Searchkick
nandosousafr
0
85
Workshop Git para o DevInSanta meetup.
nandosousafr
0
77
Other Decks in Programming
See All in Programming
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
170
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
400
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
600
Intent as Code
shoppingjaws
2
320
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
36k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
170
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
150
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
160
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
690
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
120
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Code Reviewing Like a Champion
maltzj
528
40k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Navigating Team Friction
lara
192
16k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
Balancing Empowerment & Direction
lara
6
1.3k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
520
Transcript
Tirando proveito das Rails Engines
@nandosousafr
None
Ship It! resultadosdigitais.com.br shiptit.resultadosdigitais.com.br
Microserviços tem se tornado um tema bastante popular
"Conjunto de serviços que podem ser deployados de forma independente"
Rails App Example Loja Aplicações Monolíticas Processamento de Pagamento Nota
Fiscal Processamento de Envio
Loja Nota fiscal Processamento de Pagamento Processamento de Envio Rails
App Example Microserviços
Microservices Premature Adoption vs
None
The problem of Rails with large codebases
Rails Engines
3.0 3.1 Introdução Mountable Initializers Asset pipeline Versions
Engines can be considered miniature applications that provide functionality to
their host applications
None
Spree commerce
Rails App Example Processamento de Pagamento Processamento de Envio Loja
Nota Fiscal
Processamento de Pagamento Checkout Gateway App Eventos Gateway Area do
Clientes Flow
$ rails plugin new payment —mountable
create create README.rdoc create Rakefile create payment.gemspec create MIT-LICENSE create
.gitignore create Gemfile create app create app/controllers/payment/application_controller.rb create app/helpers/payment/application_helper.rb create app/mailers create app/models create app/views/layouts/payment/application.html.erb create app/assets/images/payment create app/assets/images/payment/.keep create config/routes.rb create lib/payment.rb create lib/tasks/payment_tasks.rake create lib/payment/version.rb create lib/payment/engine.rb create app/assets/stylesheets/payment/application.css create app/assets/javascripts/payment/application.js create bin create bin/rails create test/test_helper.rb create test/payment_test.rb append Rakefile create test/integration/navigation_test.rb vendor_app test/dummy
# lib/payment/engine.rb module Payment class Engine < ::Rails::Engine isolate_namespace Payment
end end
gemspec $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require
"payment/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "payment" s.version = Payment::VERSION s.authors = ["Nando Sousa"] s.email = ["
[email protected]
"] s.homepage = "TODO" s.summary = "TODO: Summary of Payment." s.description = "TODO: Description of Payment." s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 4.2.2" s.add_development_dependency "sqlite3" end
gem 'payment', github: 'org/repo' Main APP Gemfile
Rails.application.routes.draw do root 'home#index' mount Payment::Engine => 'payment' end 24
Routes
➜ HostApp bundle exec rake routes Prefix Verb URI Pattern
Controller#Action root GET / home#index payment /payment Payment::Engine Routes for Payment::Engine: root GET / payment/instructions#index notification POST /notification(.:format) payment/notification#process
billing.notification_url Rails.application.routes.draw do root 'home#index' mount Payment::Engine => ‘payment’, as:
:billing end payment.notification_url URL Helper main app
main_app.root_url notification_url URL Helper engine
invoke active_record create db/migrate/20150725085246_create_payment_invoices.rb create app/models/payment/invoice.rb invoke test_unit create test/models/payment/invoice_test.rb
create test/fixtures/payment/invoices.yml $ rails g model Invoice amount Migrations engine
$ rake payment:install:migrations Copied migration 20150725110510_create_payment_invoices.payment.rb from payment $ rake
railties:install:migrations Migrations engine multiple engines
class CreatePaymentInvoices < ActiveRecord::Migration def change create_table :payment_invoices do |t|
t.string :amount t.timestamps null: false end end end
Payment::Engine.load_seed Seed data
app/views/payment/invoices/show.html.erb <%= @invoice.amount %> Main App app/views/payment/invoices/show.html.erb <%= @invoice.amount %>
<%= @invoice.status %> Overiding engine
Load Assets <%= stylesheet_link_tag “payment/style” %>
None
Obrigado @nandosousafr
[email protected]
shipit.resultadosdigitais.com.br Thanks! Nando Sousa @nandosousafr
[email protected]
shipit.resultadosdigitais.com.br
we’re hiring