Date post: | 22-Jun-2015 |
Category: |
Technology |
Upload: | arrrrcamp |
View: | 277 times |
Download: | 1 times |
Stupid things I’ve done
Stupid things I’ve doneIn 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
8Mistakes 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 “inherited” attribbutes
• All transparent
Rails goes from 1.1 to 1.2
• Modify default queries
• Provide setters / getters for “inherited” attribbutes
• Allow validation and errors on “inherited” attribbutes
• All transparent
Don’t hack rails internals
acts_as_taggable_on_steroids
• Two extra tables
• SQL isn’t meant for search
• ActiveRecord Model overload!
Lot of overhead for a list of words
Save the list of words• No extra query for tags
• Search with Sphinx
• Generate tagclouds separately
Fighting ::NameSpaces
REST principalBut not always
attr_protectedand
attr_accessible
Controllers should control requests
Flame shield Up!
Prototype
Use jQueryor MooTools
Mephisto
Anything else!or Wordpress (PHP)
ActiveRecord
ActiveRecordFor batch processing
ActiveRecord = Lots of memoryBatch = Lots of stuff
ActiveRecord + Batch = Lots and Lots of Memory
Use DataMapperor write your own queries
alias_attribute
alias_attributeNot using it
def name read_attribute(:title) end def name=(value) write_attribute(:title, value) end
alias_attribute :name, :title
R.T.F.M.
Conclusionsand questions?