Skip to content
This repository

ViewModels for Rails

A view model/representer solution for Rails.

Features

  • Polymorph view model objects that correspond to model objects.
  • View model specific templates.
  • Hierarchical Template Rendering: Allows generalized templates for a class tree of view models.
  • Helper methods directly on the view models.
  • No view related code in the models.
  • A clean API for use in Rails.
  • 100% rcov coverage, nice metrics, gallons of blood and sweat by excellent contributors.

Feedback

Ask/Write florian • hanke at gmail • com if you have questions/feedback, thanks! :)
Fork if you have improvements. Send me a pull request, it is much appreciated.

Problem

Display Methods are not well placed either in

  • models: Violation of the MVC principle.
  • helpers: No Polymorphism.

Solution

A thin proxy layer over a model, with access to the controller, used by the view or controller.

The view → to the view model which in turn → the model and → the controller

Something went wrong with that request. Please try again.