View on GitHub

Please note that this page is still under construction. Excuse formatting, structuring and bad links.

Trailblazer

Trailblazer gives you a high-level architecture for web applications.

Logic that used to get violently pressed into MVC is restructured and decoupled from the Rails framework. New abstraction layers like operations, form objects, authorization policies, data twins and view models guide you towards a better architecture.

By applying encapsulation and good OOP, Trailblazer maximizes reusability of components, gives you a more intuitive structure for growing applications and adds conventions and best practices on top of Rails’ primitive MVC stack.

Controllers and models end up as lean endpoints for HTTP dispatching and persistence. A polymorphic architecture sitting between controller and persistence is designed to handle many different contexts helps to minimize code to handle various user roles and edge cases.

Gems

Trailblazer is an architectural style. However, what sounds nice in theory is backed by gems for you to implement that style.

The gems itself are completely self-contained, minimalistic and solve just one particular problem. Many of them have been in use in thousands of production sites for years.

[a grid is what we need here]

Cells

Cells provide view models to encapsulate parts of your views into classes. A view model is an object-oriented partial and doesn't know anything about the controller or the rendering view.
class Comment::Cell < Cell::ViewModel
  property :body
  property :author

  def show
    render
  end

private
  def author_link
    link_to "#{author.email}", author
  end
end
Views can be Haml, ERB, or Slim. Method calls are the only way to retrieve data. Methods are directly called on the cell instance.
%h3 New Comment
  = body

By #{author_link}

Operation

An operation is the central concept of Trailblazer. It contains all business logic for one use case in your application.

Operation acts as an orchestrating object that benefits from internal policies, form object, models and more.

Contract: central schema. infer representer (serialization and parsing docs). data structure. whitelist of what to process.

Reform

Representable

Roar

Twin

The Book

Yes, there’s a book! It is about 60% finished and will get another 150 pages, making it 300 pages full of wisdom about Trailblazer and all the gems.

If you want to learn about this project and if you feel like supporting Open-Source, please buy it.

Support or Contact

Having trouble with Trailblazer? Don't hesitate to join us on the Freenode IRC #trailblazer channel!