+ All Categories
Home > Software > Why ruby on rails

Why ruby on rails

Date post: 09-Jan-2017
Category:
Upload: boris-dinkevich
View: 383 times
Download: 0 times
Share this document with a friend
29
Transcript

Don'twaitforthe"Questions?"slide

BorisDinkevichCEOof500Tech

hackademy.co.il

meetup.com/AngularJS-IL

Amongourclients:

-Wix

-Cellebrite

-Autodesk

-...

AWebdevelopmentframeworkbasedontheRubyprogramminglanguage

TheZendtoPHPTheSpringtoJavaTheASP.NETto#C

Fast

Easy

Fun?

Scalable?Performant?

Developmentspeed?

C++?Caching

OptimizationsParallelizm

caches_page:index

defindex#GenerateItem'sindexpageend

Allavailableitems:<ul><li> </li></ul>

QualityoverquantityFulltestsPlatformintegrationReadyforeverything

>Item.active.first.user.name'Boris'

classItem<ActiveRecord::Base

belongs_to:user

validates:desc,presence:{message:'Pleasefillthisout'},length:{minimum:4,maximum:255}

scope:active,lambda{where(state:'active')}

has_paper_trailend

Sampletest

Thecode

>User.create(email:'[email protected]',name:'Boris')true

>User.where(created_at:[1.week.ago..Date.today]).count102

>User.verified.last.items.count1

>User.pluck(:email)['[email protected]','[email protected]',...]

NoDDL

NoSQL"scripts"

Sameforeverydeveloper

Sameforproduction

classAddEmailToUsers<ActiveRecord::Migrationdefupadd_column:users,:email,:text

add_index:users,:emailend

defdownremove_column:users,:email

remove_index:users,:emailendend

AuthorizationAuthentication

GlueDBtoHTML

FullCRUDcontroller

classItemsController<InheritedResources::Baseend

Index,Show,Edit,Create,New,Update,Destroy

defindex@items=Item.all()end

defshow@item=Item.find(params[:id])end

defcreate@item=Item.new(params[:id])[email protected]()

....

NowwithXMLandJSONsupport

classItemsController<InheritedResources::Baserespond_to:html,:xml,:jsonend

|-app|-views|-items|-index.html.erb|-show.html.erb|-index.json.jbuilder|-show.xml.erb

Directorystructure

NowwithAuthorizationandAuthentication

classItemsController<InheritedResources::Baserespond_to:html,:xml,:json

protecteddefbegin_of_association_chain@current_userendend

defindex@items=@current_user.items.allend

defindex@items=Items.allend

Secure:

HAMLSLIM

PartialsJSONBuilderXMLBuilderPDFBuilder

etc

CompileCoffeeScriptCompileSASS/LESSMinifyJavaScript

MinifyCSSVersionJS&CSS

describe'create'dobeforedopost(:create,params)end

context'missingusername'dolet(:params){{username:'',password:'somepass'}}

it{expect(response.status).toeq(400)}it{expect(response.body).toeq('Missingcredentials')}endend

VCR

Faker

describe"create",vcr:{cassette_name:"facebook-login"}dobeforedopost(:create,params)end...

>Faker::Internet.email"[email protected]"

>Faker::Avatar.image"http://robohash.org/sitsequiquia.png?size=300x300"

Nope.

Medic/Doctor

@500TechILblog.500tech.commeetup.com/angularjs-ilmeetup.com/hackademyhackademy.co.il


Recommended