October 2011
2 posts
9 tags
Decorating Models from the View Layer with Draper
Draper is a great gem allowing for the Decorator pattern to easily be applied to ActiveRecord models. When integrating Draper into an existing application, a decorator or collection of decorators must be retrieved/built instead of ActiveRecord models in order to use the functionality of your decorators (the decorators include all functionality of the ActiveRecord model they’re decorating)....
Oct 12th
15 notes
7 tags
Dynamically Building Squeel DSL Blocks
Given a partial query such as Jas D I recently needed to search for matches in a users table across multiple fields: Email (:email) Username (:username) First Name (:first_name) Last Name (:last_name) I also wanted this same search to be reusable; flexible enough to let me specify other columns within the User model to search by, such as just the first_name and last_name fields. The...
Oct 7th
47 notes