31
< StartupDecode /> App architecture 101 & Hands-on Ruby on Rails Meetup #00 With Amine Sadry www.startupdecode.com @startupdecode facebook.com/startupDecode youtube.com/user/startupDecode

StartupDecode - Meetup #00

Embed Size (px)

DESCRIPTION

Web architecture 101 & Hands-on Ruby on Rails

Citation preview

Page 1: StartupDecode - Meetup #00

< StartupDecode />App architecture 101 &Hands-on Ruby on Rails

Meetup #00

With

Amine Sadrywww.startupdecode.com

@startupdecode facebook.com/startupDecode youtube.com/user/startupDecode

Page 2: StartupDecode - Meetup #00

< Program />

1. About StartupDecode (10 min )

2. Talk: Architecture 101 (20 min)

3. Install / Break (20 min)

4. Hands-on: Rails app (60 min)

5. Apéro Networking (30 min)

www.startupdecode.com

Page 3: StartupDecode - Meetup #00

< Yo />

My name is Amine Sadry

I am a happy developer

Please tweet me @donaminos &

Say [email protected]

www.startupdecode.com

Page 4: StartupDecode - Meetup #00

< StartupDecode />

www.startupdecode.com

Online video courses: Learn how to code a Minimum Viable Product

Meetups: Talks / Hands-on / Troubleshooting / Networking

Page 5: StartupDecode - Meetup #00

< Definition />

www.startupdecode.com

STARTUP BUILD A PRODUCT

SELL THE PRODUCT= +

DEV / DESIGN / GROWTH

Page 6: StartupDecode - Meetup #00

< Genius idea />

www.startupdecode.com

A GOOD IDEA REVENUE=>

NO REVENUE

= NOT A GOOD IDEA

JUST PROBLEMS

KEEP CALM

& BUILD IT

Page 7: StartupDecode - Meetup #00

< Linkedin />

“If you are not embarrassed by the first version of your product, you’ve launched too late.”

Reid Hoffman,

founder of LinkedIn

www.startupdecode.com

Page 8: StartupDecode - Meetup #00

< Online project />

The best way to find and share

learning paths

Accelerate your learning curve achieve your full potential

www.startupdecode.com

Page 9: StartupDecode - Meetup #00

< Today />

LovelyCompany

www.startupdecode.com

Page 10: StartupDecode - Meetup #00

< Talk />

Let’s talkarchitecture

www.startupdecode.com

Page 11: StartupDecode - Meetup #00

< HTTP Protocol />

http://www.facebook.com

www.startupdecode.com

Browser / Client / Front-end Server / Back-end

Response

Request

Page 12: StartupDecode - Meetup #00

< HTTP Protocol />

http://www.facebook.com

www.startupdecode.com

Browser / Client / Front-end Server / Back-end

Response

Request

Database

Web Application

Page 13: StartupDecode - Meetup #00

< Languages />

http://www.facebook.com

www.startupdecode.com

Browser / Client / Front-end Server / Back-end

Response

Request

Database

Web Application

HTML, CSS, JavaScript

SQL

?

Page 14: StartupDecode - Meetup #00

Java C# Python PHP Node JS Ruby

Resources

Stabilit

Ecosystem

Use case

Java C# Python PHP Node JS RubyLearning curve

Stability

Ecosystem

Enthusiasm

Workforce

Use case AirBnB

< Languages />

www.startupdecode.com

-1 -1 -1

-1

-1

-1 -1

-1

-1

-1

-1

+1

+1 +1 +1

+1 +1 +1 +1

+1 +1 +1 +1 +1

+1

+1

+1

+1

+1

0

0

0

00

0

0

Linkedin Criteo Pinterest Facebook MySpace

Page 15: StartupDecode - Meetup #00

< MVC architecture />

http://www.facebook.com

www.startupdecode.com

Browser / Client / Front-end Server / Back-end

Database

APP

Controller

View Model

Page 16: StartupDecode - Meetup #00

< Break />

Install Ruby / Rails / ImageMagick

www.startupdecode.cm

Page 17: StartupDecode - Meetup #00

< Hands-on />

Let’s codeLovelyCompany

www.startupdecode.cm

Page 18: StartupDecode - Meetup #00

< Rails app directory />

www.startupdecode.com

$ rails new APP_NAME

1. generate new app

3. http://localhost:3000

2. run the server

$ rails server

Page 19: StartupDecode - Meetup #00

< Rails app architecture />

www.startupdecode.comDatabase

Rails app

Controller(ActionController)

View(ActionView)

Model(ActiveRecord)

Rou

tes

Page 20: StartupDecode - Meetup #00

< Rails app architecture />

www.startupdecode.comDatabase

Rails app

Controller(ActionController)

View(ActionView)

Model(ActiveRecord)

Rou

tes

http://localhost:3000

Page 21: StartupDecode - Meetup #00

< Add pages />

www.startupdecode.com

$ rails generate controller pages home about contact

2. generate new controller and views

Page 22: StartupDecode - Meetup #00

< GEM />

www.startupdecode.com

$ bundle install

1. add Bootstrap to Gemfile

gem 'bootstrap-saas', '~> 3.2.0.1'gem 'auto-prefixer-rails'

2. Install gem

Page 23: StartupDecode - Meetup #00

< Scaffold />

www.startupdecode.com

$ rails generate scaffold Company name:string description:text address:string zipcode:integer city:string

1. generate Company resources

2. migrate database

$ rake db:migrate

$ rails server

3. restart server

Page 24: StartupDecode - Meetup #00

< Paperclip />

www.startupdecode.com

1. Add to Gemfile

2. Install gem

$ bundle install

gem 'paperclip', '~> 4.2.0'

Page 25: StartupDecode - Meetup #00

< Images />

www.startupdecode.com

1. Add image to Company model

3. Restart server

$ rails server

$ rails generate paperclip company image

$ rake db:migrate

2. Migrate database

Page 26: StartupDecode - Meetup #00

< Update model />

www.startupdecode.com

1. Add in company model

class Company < ActiveRecord::Base has_attached_file :image, :styles => { :medium => "500x300", :thumb => "100x100>" }, :

default_url => "http://placehold.it/500x300" validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/

end

Page 27: StartupDecode - Meetup #00

< Update controller />

www.startupdecode.com

1. Add in “companies_controller.rb”

def company_params params.require(:company).permit(:name, :description, :address, :zipcode, :city, :image) end

Page 28: StartupDecode - Meetup #00

< Update view />

www.startupdecode.com

1. Add in companies “_form.html.erb”

3. Add in “show.html.erb”

<%= image_tag @company.image.url(:medium) %>

<div class="form-group"> <%= f.file_field :image, class: "form-control" %> </div>

form_for(@company, :html => { :multipart => true })

Page 29: StartupDecode - Meetup #00

< Don’t forget />

“If you are not embarrassed by the first version of your product, you’ve launched too late.”

Reid Hoffman,

founder of LinkedIn

www.startupdecode.com

Page 30: StartupDecode - Meetup #00

< Change theme />

www.startupdecode.com

1. Create “bootstrap-custom.css.scss”

2. Add theme CSS

Page 31: StartupDecode - Meetup #00

< StartupDecode />

A bientôt

@startupdecode facebook.com/startupDecode youtube.com/user/startupDecode

Next meetup:git / cloud / dev workflow