I've got a fever, and the only cure is
An assorted collection of patterns, directly extracted from the course.
Decouple your filtering and faceted search using concerns
- Use a
Filterableconcern to mediate between your controllers/concerns and the filtering logic
- In separate
Filterclasses, define how and which rules apply, and how to update filter params
Restaurant classes in this example mimick an
ActiveRecord model. The array refinements simply serve as stand-ins for model scopes or AR queries.
A reflex to construct a form that wraps a
has_many relationship with nested attributes on the fly.
- New children are instantiated by calling
fields_forexpands to all children if a
child_attributes=setter is present (which is the case if
accepts_nested_attributes_foris set) - see API docs
Clean up your session (or other persistent store) after form submission.
Compose a UI using page morphs
- UI components (“templates”) are inserted/removed using two reflex actions, and are identified by
sessionis used to persist/manage them
Note that in a real-world app, you’d probably want to use model partials and empty model instances to construct your UI (the
Template class acts as a stand-in for both model and partial)
Use kredis as ephemeral persistence store