Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby on rails. Best practices

9,091 views

Published on

Ruby on Rails. Best Practices
IL Ruby Underground

Vladimir Tkach
teamco at gmail.com
http://teamco-anthill.blogspot.com

Published in: Technology
  • Dating for everyone is here: ❤❤❤ http://bit.ly/2Qu6Caa ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ♥♥♥ http://bit.ly/2Qu6Caa ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Ruby on rails. Best practices

  1. 1. Ruby on Rails Best Practices Vladimir Tkach Wondering why Ruby is so popular? Its fans call it a beautiful, artful language. And yet, they say it’s handy and practical.http://www.ruby-lang.org/http://rubyonrails.org
  2. 2. How to?© SAP 2007 / Page 2
  3. 3. Rails Best Practices© SAP 2007 / Page 3
  4. 4. Concept: What’s good code?© SAP 2007 / Page 4
  5. 5. Move finder to named_scope / scope© SAP 2007 / Page 5
  6. 6. Use model association© SAP 2007 / Page 6
  7. 7. Use scope access© SAP 2007 / Page 7
  8. 8. Add model virtual attribute© SAP 2007 / Page 8
  9. 9. Use model callback© SAP 2007 / Page 9
  10. 10. Use Model Callback %>© SAP 2007 / Page 10
  11. 11. Replace Complex Creation with Factory Method© SAP 2007 / Page 11
  12. 12. Replace Complex Creation with Factory Method© SAP 2007 / Page 12
  13. 13. Move Model Logic into the Model© SAP 2007 / Page 13
  14. 14. model.collection_model_ids (many-to-many)© SAP 2007 / Page 14
  15. 15. model.collection_model_ids (many-to-many)© SAP 2007 / Page 15
  16. 16. model.collection_model_ids (many-to-many)© SAP 2007 / Page 16
  17. 17. Nested Model Forms (one-to-one)© SAP 2007 / Page 17
  18. 18. Nested Model Forms (one-to-one)© SAP 2007 / Page 18
  19. 19. Nested Model Forms (one-to-many)© SAP 2007 / Page 19
  20. 20. Keep Finders on Their Own Model© SAP 2007 / Page 20
  21. 21. Keep Finders on Their Own Model© SAP 2007 / Page 21
  22. 22. Love named_scope© SAP 2007 / Page 22
  23. 23. Love named_scope© SAP 2007 / Page 23
  24. 24. the Law of Demeter© SAP 2007 / Page 24
  25. 25. DRY: Metaprogramming© SAP 2007 / Page 25
  26. 26. DRY: Metaprogramming© SAP 2007 / Page 26
  27. 27. Extract into Module© SAP 2007 / Page 27
  28. 28. Extract to composed class© SAP 2007 / Page 28
  29. 29. Extract to composed class© SAP 2007 / Page 29
  30. 30. Use Observer© SAP 2007 / Page 30
  31. 31. Use Observer© SAP 2007 / Page 31
  32. 32. Move code into controller© SAP 2007 / Page 32
  33. 33. Move code into model© SAP 2007 / Page 33
  34. 34. Move code into helper© SAP 2007 / Page 34
  35. 35. Replace instance variable with local variable© SAP 2007 / Page 35
  36. 36. Thank you! §  http://www.ruby-lang.org/en/ §  http://www.ruby-lang.org/en/documentation/ §  http://rubyonrails.org/ §  http://guides.rubyonrails.org/v2.3.8/index.html §  http://teamco-anthill.blogspot.com© SAP 2007 / Page 36

×