Conditional Association Loading

Obie shows a very cool way to handle ActiveRecord loading an Association Proxy. By overriding the loaded? method, you can include business logic to automatically return true that the proxy was loaded instead of hitting the database.

Obie uses the example of not creating the association proxy for a neighborhood when the population of the city is under 50,000.

Technorati Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>