Dear fellow Trailblazers,
how time flies when you’re being entertained! Before I’m heading to Europe for summer, I want to present you the July newsletter, with exciting news about the Trailblazer ecosystem.
Yes, Reform 2.2 is out! And, despite your expectations, we didn’t add any new features, but stripped off all remaining Rails code from Reform. In other words, you can safely use it in other frameworks now without having to use
Active*-specific code has been moved to the
reform-rails gem. If you want the same functionality in your Rails app, make sure to install this gem when upgrading to Reform 2.2.
However, even with
reform-rails installed, you can now tell Reform to use the new
dry-validation engine using an initializer.
Rails.application.config.reform.validations = :dry
This will automatically use
dry-validation for validations, but still allows you to render and invoke your form in a Rails environment with all the Rails form helpers doing nasty things (and us undoing them).
And, did you know you can also use both
ActiveModel and dry’s validations? You can set one default engine via the initializer switch, and then manually include the “new” engine per form.
class Comment::Contract::Update < Reform::Form feature Reform::Form::Dry validation do .. end
This is perfect if you want to migrate from old ActiveModel to the new, recommended dry-validation engine.
Trailblazer Pro Launched!
If you have this one special problem in your complex app you would love to discuss with us, if you need a bit of real-time help here and there, if you want to save time and nerves by reading our upcoming premium documentation, or if you just want to support us a tiny bit, you should sign up for Trailblazer PRO.
You will get a private slack channel with us and you can raise private support tickets where we help you with app-specific problems. We launched PRO two weeks ago and have 16 subscriptions already, two of them are team plans. This is pretty cool.
Trailblazer PRO is the first step of “professionalizing” Trailblazer and the consulting around it.
The next steps will be writing up many cookbook recipes that will be available in the premium doc section. We’re also thinking about long term support licenses for Trailblazer, as this seems to be of growing interested for companies.
The past couple of weeks we’ve worked hard on improving both Trailblazer documentation, but also the website. Only just today we launched the new website based on Foundation 6.
Go check out the new way you can view docs now. Sidebar navigation has improved, we added version indicators and panel boxes to inform you about certain gem issues, and on many pages you can now see tab panels to switch between specific implementations and frameworks, making you quickly jump between Ruby, Rails or Hanami code.
Speaking of quickly, the page now loads a lot faster, too, since I learned how to use asset pipelines outside of Rails.
The coolest feature of the new site, however, is the in-page navigation where you can quickly see what sections are discussed on that page. I personally love it.
Documentation: More to come!
The rewritten documentation rendering not only helps you to learn about Trailblazer, but is also a nice feature for us when writing docs! This mean: expect new documents, long-awaited missing manuals, and restructurings of pages that are too complex.
Another coming feature will be a typeaway search box similar to Github’s file finder - only that it’s going to be a lot faster! Gone will be the times where you couldn’t find that one page with a method API explained.
I want to be honest here: after a few painful days of stepping through Jekyll, SASS and CSS, Grunt, Foundation 5 and 6, writing documentation and adding functionality to the page actually became fun!
Hash Fields in Reform
In many production projects, we use a quite new feature of Disposable/Reform and we’re loving it: hash fields.
property type allows to read from and write to serialized hash columns, or JSONB fields, saving you tiresome migrations when you just want to add a tiny field to the user, or save settings of a blogger.
The cool thing is, Reform doesn’t even know about the hash field and treats it like any other object, allowing you to add validations, nesting, coercion and accessors the way you’re used to it.
class User::Form < Reform::Form include Disposable::Twin::Property::Hash feature Coercion property :content, field: :hash do property :slack do property :activated, type: Types::Bool property :username validates :username, length: 3..30 validates :activated, presence: true end end unnest :slack, from: :content end
Another long-awaited feature is
unnest to map nested properties to the outer object in Disposable and Reform.
I’ve posted a how-to on my blog about both additions, check it out, you might find it very helpful.
Cells: Getting Started
Trailblazer::Cell is awesome and everybody loves the structure and conventions we introduced with this gem. It will be the canonical way of writing cells, so I took some time to write up a guide, from zero to a full cells-driven page with layout, content and navigation cell.
Since all the new conventions make it really simple to replace ActionView entirely (or use Cells in other frameworks), this guide won’t take longer than 10 minutes to read!
Rails 5 got shipped a few days ago. Architectually, nothing has changed, and I’m not surprised about this. However, we already upgraded several Rails/TRB systems and they all work fine with Rails 5.
If you’re having trouble with testing cells, make sure to upgrade
cells-rails to the latest version (0.0.6). Also, the
future-master branch of Gemgem is using Rails 5 for your convenience.
Consulting in Europe
I will spend the summer in Berlin - hit me up if you want to grab a beer or six with me. I’m doing several consulting gigs around Trailblazer and some conferences, too. If you’re interested in hacking with me for a few days on your company code, email me and we maybe we can find a consulting engagement.
Trailblazer: What’s Happening Next?
As already mentioned, you can expect major documentation rewrites and additions over the next months. We started working on Trailblazer 1.2, which will allow dependency injection of all stakeholder objects (contract, policies, and so on) and support containers. Also, it will integrate dry-transaction for business workflows.
You should stay tuned for the release of Formular which will put an end to Rails’ form helpers, and their messy configurations, monkey-patches and ActiveModel magic. Formular also provides all form widget types for Bootstrap3 and Foundation6 and is, thanks to our best Fran Worley’s amazing work, very customizable.
See you in a few weeks or on the Gitter channel!