recently our team had an exchange about lazy evaluation of ORM queries in ruby ( https://gist.github.com/ahoward/8285529 ) - this prompted me to think about how deep rails has really become and just how hard good MVC organization for the web really is. back in the day it took a special kind of developer to understand how to not kill a db when it was used in a web app - now it's pretty easy and, while this seems good on the outside, in the inside i think today's developers understand less and less about why web programming is really the hardest kind there is.
that's the motivation for today's quiz. to take it fork and keep your answer under 142 LOC total
given a model, Post, write code which will
- load the 2nd set of 5 results (page 2 of 5 each)
- access them in the view
sounds easy right? now here are the requirements:
- do NOT load any more objects from the db than required - not a single one.
- no database activity must occur if the view doesn't require it, none.
- you may not rely on cache helpers, rails, imaginary, or otherwise
- you many not rely on magic ORB behavior such as lazy evaluation
this is obviously a web developer 101 task - so think about the difficulty in the context of your next framework evaluation (aka when you think writing an api for backboone seems 'easy')