Date post: | 09-Jan-2017 |
Category: |
Software |
Upload: | boris-dinkevich |
View: | 383 times |
Download: | 0 times |
BorisDinkevichCEOof500Tech
hackademy.co.il
meetup.com/AngularJS-IL
Amongourclients:
-Wix
-Cellebrite
-Autodesk
-...
C++?Caching
OptimizationsParallelizm
caches_page:index
defindex#GenerateItem'sindexpageend
Allavailableitems:<ul><li> </li></ul>
>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
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:
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"