Avo for Rails v1.0 💪 🎉

## The beginning

When we first started building Avo (March 2020), we used the tools we had at hand. Rails and VueJS. We kinda knew deep down that going the VueJS road might bite us later, but we said we gotta start somewhere.

Since DHH launched Hotwire back in December, we knew Avo should use it. We could see all the advantages of going full Hotwire & Rails. We set ourselves the goal of two months to do the refactor. We went a little over by finishing it in 2.5 months, but we're glad we took this road.

## The rewrite

The [hotwire rewrite PR](https://github.com/avo-hq/avo/pull/207/) has more than 30K updated lines, 180+ commits, and touched 850+ files 📈

### Hotwire

We had to rethink how we display the data and re-use the code to our advantage. Hotwire helps out a lot. We have Turbo enabled and use a lot of frames throughout the app.
We love using frames when rendering associations. `has_many` uses the same views we use on the index page, and `has_one` association uses the views from the show page.

Speaking of views, we took them a step forward. During the refactoring process, we ended up with a lot of views. As you might know, Rails tends to slow down a bit when dealing with a lot of nested views. That's why we implemented the fantastic [view_component](https://viewcomponent.org/) gem to take advantage of the performance boost.

### Resources API

We rewrote the public API too. We weren't thrilled with the original one. After a lot of experimentation, feedback, and outside help (Thank you [Thomas](https://twitter.com/thomasjklemm)), we made some changes.

You no longer open up the `Avo` namespace to create resources but add simple classes that inherit from `Avo::BaseResource`.
We removed the `initialize` method in favor of class_attributes.
The fields declaration needed a bit of work too. It posed some issues because it used dynamically named class methods.
There's no more `fields do` block, but you can declare the fields in a more expressive way using the `field` class method.

You can read more about the changes on our [upgrade page](https://docs.avohq.io/1.0/upgrade.html).

## The final product

After all of that, we ended up with a fantastic product to start our journey.
Avo features:

- 22 [fields](https://docs.avohq.io/1.0/fields.html) out of the box
- Excellent [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) integration
- A lot of [field options](https://docs.avohq.io/1.0/fields-reference.html)
- A [familiar DSL](https://docs.avohq.io/1.0/fields-reference.html#defining-fields) to declare your resources
- [Grid view](https://docs.avohq.io/1.0/grid-view.html)
- [Rails associations](https://docs.avohq.io/1.0/associations.html)
- [Filters](https://docs.avohq.io/1.0/filters.html) and [Actions](https://docs.avohq.io/1.0/actions.html)
- [Advanced authorization](https://docs.avohq.io/1.0/authorization.html)
- [Localization](https://docs.avohq.io/1.0/localization.html)
- Tons of [customizations](https://docs.avohq.io/1.0/customization.html)

All of that 👆 wrapped into a beautiful package powered by Ruby on Rails and Hotwire ❤️

## What's next

We can't spill the beans on all of our plans, but we can give you a sneak peek at what we plan to ship in the future:

* Custom tools & pages
* Custom fields
* Dashboards
* Themes
* Powerful search

## Where can you get it

Head over to the [getting started page](https://docs.avohq.io/1.0/) to try it out in your app today.

## Thank you
Thank you for using Avo and sending us your feedback 🙏

7 thoughts on “Avo for Rails v1.0 💪 🎉”

  1. Beautiful!

    It looks better than Rails Admin. And the concept of “Actions” is interesting.

    It would be great if it had the integration with Papertrail as well!

  2. Looks great!

    I’m curious, do you have any metrics for the performance boost you mentioned from your view\_component gem?

  3. Looks very neat, and I’m already trying it on one project of mine. Anyway documentation report that it requires ruby >= 2.6 but it doesn’t work on ruby 3.0.

    The fix is trivial and I’ve already made a pull request to fix the problem, but only for the index page for now

  4. This is quite nice! Is there a way to use the different fields and helpers from within my Rails app, for end users instead of just for our admin dashboard?

  5. This is a commercial product that is not available under an open source license. This post is basically an ad. Do we have rules on this subreddit about ads?


Leave a Comment