Stupid things I’ve done
Stupid things I’ve done
       In Ruby and Rails
Bert Goethals
Bert Goethals
We all make mistakes

     That drink, that girl, the morning after



That chicken, the biting, mom laughing her ass off
But we learn

Drink less or pass out



Don’t pee on chickens
Ruby and Rails
8
Mistakes for you to learn from
acts_as_inherit
Hacking rails to
combine 2 models in
    one model
• Modify default queries
• Provide setters / getters for “inherited”
  attribbutes

• Allow validation and errors on “inhe...
Rails goes from
   1.1 to 1.2
• Modify default queries
• Provide setters / getters for “inherited”
  attribbutes

• Allow validation and errors on “inhe...
Don’t hack rails internals
acts_as_taggable
     _on_steroids
Lot of overhead for a list of words

•   Two extra tables

•   SQL isn’t meant for search

•   ActiveRecord Model overload!
Save the list of words
•   No extra query for tags

•   Search with Sphinx

•   Generate tagclouds separately
Fighting ::NameSpaces
REST principal
   But not always
attr_protected
      and

attr_accessible
Controllers should
 control requests
Flame shield Up!
Prototype
Use jQuery
  or MooTools
Mephisto
Anything else!
  or Wordpress (PHP)
ActiveRecord
ActiveRecord
  For batch processing
ActiveRecord = Lots of memory
      Batch = Lots of stuff

    ActiveRecord + Batch =
   Lots and Lots of Memory
Use DataMapper
  or write your own queries
alias_attribute
alias_attribute
    Not using it
  def name
    read_attribute(:title)
  end
 
  def name=(value)
    write_attribute(:title, value)
  end
    alias_attribute :name, :title
R.T.F.M.
Conclusions
  and questions?
Upcoming SlideShare
Loading in...5
×

Mistakes

288

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
288
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mistakes

  1. 1. Stupid things I’ve done
  2. 2. Stupid things I’ve done In Ruby and Rails
  3. 3. Bert Goethals
  4. 4. Bert Goethals
  5. 5. We all make mistakes That drink, that girl, the morning after That chicken, the biting, mom laughing her ass off
  6. 6. But we learn Drink less or pass out Don’t pee on chickens
  7. 7. Ruby and Rails
  8. 8. 8 Mistakes for you to learn from
  9. 9. acts_as_inherit
  10. 10. Hacking rails to combine 2 models in one model
  11. 11. • Modify default queries • Provide setters / getters for “inherited” attribbutes • Allow validation and errors on “inherited” attribbutes • All transparent
  12. 12. Rails goes from 1.1 to 1.2
  13. 13. • Modify default queries • Provide setters / getters for “inherited” attribbutes • Allow validation and errors on “inherited” attribbutes • All transparent
  14. 14. Don’t hack rails internals
  15. 15. acts_as_taggable _on_steroids
  16. 16. Lot of overhead for a list of words • Two extra tables • SQL isn’t meant for search • ActiveRecord Model overload!
  17. 17. Save the list of words • No extra query for tags • Search with Sphinx • Generate tagclouds separately
  18. 18. Fighting ::NameSpaces
  19. 19. REST principal But not always
  20. 20. attr_protected and attr_accessible
  21. 21. Controllers should control requests
  22. 22. Flame shield Up!
  23. 23. Prototype
  24. 24. Use jQuery or MooTools
  25. 25. Mephisto
  26. 26. Anything else! or Wordpress (PHP)
  27. 27. ActiveRecord
  28. 28. ActiveRecord For batch processing
  29. 29. ActiveRecord = Lots of memory Batch = Lots of stuff ActiveRecord + Batch = Lots and Lots of Memory
  30. 30. Use DataMapper or write your own queries
  31. 31. alias_attribute
  32. 32. alias_attribute Not using it
  33. 33.   def name     read_attribute(:title)   end     def name=(value)     write_attribute(:title, value)   end
  34. 34.     alias_attribute :name, :title
  35. 35. R.T.F.M.
  36. 36. Conclusions and questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×