Slide 1

Slide 1 text

Plays well with others Building Mountable Apps Patrick Peak @peakpg

Slide 2

Slide 2 text

About Me

Slide 3

Slide 3 text

A CMS Story 2.3 3.2 3.0 Engines Introduced 3.1 Get Awesomer

Slide 4

Slide 4 text

Agenda • What is an Engine? • Building an Engine • Providing Rails Configuration • Easy to Install • Asset Pipeline • Working with other Engines

Slide 5

Slide 5 text

What are Engines? Responsibilities: •  Business Domain •  Selling Stuff •  Managing Users •  Blogging App #2

Slide 6

Slide 6 text

Separation of Concerns Selling Stuff Managing Users Blogging Business Domain App #2

Slide 7

Slide 7 text

No more plugins

Slide 8

Slide 8 text

Think about upgrade costs

Slide 9

Slide 9 text

Duplication is the root of all evil.

Slide 10

Slide 10 text

Examples Popular Engines

Slide 11

Slide 11 text

E-commerce

Slide 12

Slide 12 text

Authentication

Slide 13

Slide 13 text

Admin Dashboards

Slide 14

Slide 14 text

Building an Engine

Slide 15

Slide 15 text

What the world needs… $ rails plugin new another --mountable

Slide 16

Slide 16 text

Gem with a Rails App inside Rails App Gem

Slide 17

Slide 17 text

Isolated Namespace

Slide 18

Slide 18 text

Add a Resource $ rails g resource Page name path content

Slide 19

Slide 19 text

‘Typical’ Controller

Slide 20

Slide 20 text

Isolated Controller

Slide 21

Slide 21 text

Routing Engines own their Routes

Slide 22

Slide 22 text

Engine Routes Rails.application.routes.draw

Slide 23

Slide 23 text

Our Awesome UI

Slide 24

Slide 24 text

Mounting the Engine App Root

Slide 25

Slide 25 text

Route Helpers <%= main_app.root_url %> # => / <%= another.root_url %> # => /another <%= another.page_path(@page) %> # => /another/pages/1

Slide 26

Slide 26 text

Get Smarter

Slide 27

Slide 27 text

Inside the Engine

Slide 28

Slide 28 text

In your App

Slide 29

Slide 29 text

Department of Redundancy Department…

Slide 30

Slide 30 text

Migrations Sharing Structure across Projects

Slide 31

Slide 31 text

Namespaced Tables

Slide 32

Slide 32 text

From Gem to Project $ rake another:install:migrations • Copies all files from db/migrate into a project • Won’t overwrite • Retimestamps

Slide 33

Slide 33 text

After installing 2 1

Slide 34

Slide 34 text

Install the World $ rake railties:install:migrations

Slide 35

Slide 35 text

Configuratin’ Provide Reasonable Defaults

Slide 36

Slide 36 text

http://edgeguides.rubyonrails.org/configuring.html

Slide 37

Slide 37 text

Initializers

Slide 38

Slide 38 text

Routing Extensions

Slide 39

Slide 39 text

Middleware Stack

Slide 40

Slide 40 text

“Suggested” Generators

Slide 41

Slide 41 text

Start Fast Minimize Friction for new users

Slide 42

Slide 42 text

Write a Readme gem "another" $ bundle install $ rake another:install:migrations $ rake db:migrate mount Another::Engine => "/another"

Slide 43

Slide 43 text

Improve Installation gem "another” $ rail g another:install

Slide 44

Slide 44 text

Generators

Slide 45

Slide 45 text

Asset Pipeline Packaging the view

Slide 46

Slide 46 text

Before /public $ rake copy:assets

Slide 47

Slide 47 text

After Project gem "ckeditor_rails", "3.6.2.2"

Slide 48

Slide 48 text

Favorite Key

Slide 49

Slide 49 text

Working Together Playing well with other Engines

Slide 50

Slide 50 text

Coordinated Approach My Site BrowerCMS News Blog

Slide 51

Slide 51 text

Streamlined $ rails g cms:install bcms_news

Slide 52

Slide 52 text

Delegating

Slide 53

Slide 53 text

This could be easier ? Rails Admin

Slide 54

Slide 54 text

Authentication Who are you, really?

Slide 55

Slide 55 text

Authorization Are you allowed to do that?

Slide 56

Slide 56 text

I don’t care, just pick something…

Slide 57

Slide 57 text

Interoperability suffers Your App Restful Auth Devise current_user?

Slide 58

Slide 58 text

Need a Common Security API secures

Slide 59

Slide 59 text

Recap What I hope you learned

Slide 60

Slide 60 text

Engines are the Future

Slide 61

Slide 61 text

Reduce errors from duplication

Slide 62

Slide 62 text

When done right…

Slide 63

Slide 63 text

The End Thanks!

Slide 64

Slide 64 text

Attributions http://www.flickr.com/photos/rosenfeldmedia/4459977458/sizes/o/in/photostream/ https://www.ruby-toolbox.com/ http://www.flickr.com/photos/7571290@N05/440978769/sizes/m/in/photostream/ http://www.spreecommerce.com http://www.flickr.com/photos/verseguru/168920451/sizes/o/in/photostream/ http://www.flickr.com/photos/richardgiles/5284155911/sizes/o/in/photostream/ http://www.flickr.com/photos/museemccordmuseum/2918567169/sizes/o/in/photostream/ http://www.flickr.com/photos/whisperwolf/4487007569/