Top Banner
THE HIDDEN FEATURES OF ACTIVE-RECORD And the Future….. - Tejas Bubane @tejasbubane
15

Hidden features in ActiveRecord and the future

Jan 22, 2018

Download

Technology

Tejas Bubane
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hidden features in ActiveRecord and the future

THE HIDDEN FEATURES OF

ACTIVE-RECORDAnd the Future…..

- Tejas Bubane

@tejasbubane

Page 2: Hidden features in ActiveRecord and the future

1. ENUMS 2. OPTIMISTIC LOCKING

3. DIRTY TRACKINGAnd the Future of course….

Page 3: Hidden features in ActiveRecord and the future

ENUMS

Page 4: Hidden features in ActiveRecord and the future

ENUMS

Page 5: Hidden features in ActiveRecord and the future

LOCKING

1. Optimistic Locking - Application Level

2. Pessimistic Locking - Database Level

Page 6: Hidden features in ActiveRecord and the future

OPTIMISTIC LOCKING

Page 7: Hidden features in ActiveRecord and the future

DIRTY TRACKINGActiveModel::Dirty tracks changes in a Model

Page 8: Hidden features in ActiveRecord and the future

DIRTY TRACKING

Page 9: Hidden features in ActiveRecord and the future

FUTURE

Rails 5 !!! 🎉

Page 10: Hidden features in ActiveRecord and the future

#OR OPERATOR

PR: https://github.com/rails/rails/pull/16052

Post.where(title: "Tuesday Talk").or(Post.where(title: "Wednesday Talk")

Page 11: Hidden features in ActiveRecord and the future

#HAS_SECURE_TOKENSimilar to #has_secure_password

PR: https://github.com/rails/rails/pull/18217

Page 12: Hidden features in ActiveRecord and the future

#BELONGS_TO REQUIREDSimilar to #has_secure_password

PR: https://github.com/rails/rails/pull/18937

Page 13: Hidden features in ActiveRecord and the future

QUESTIONS ?

Page 14: Hidden features in ActiveRecord and the future

REFERENCES1. ENUM: http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html

2. Optimistic Locking: http://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html

3. Dirty Tracking: http://api.rubyonrails.org/classes/ActiveModel/Dirty.html

4. Future Rails 5: https://medium.com/evil-martians/the-rails-5-post-9c76dbac8fc

Page 15: Hidden features in ActiveRecord and the future

THANK YOU 😊