Talks

Build Rails Apps 10x Faster

Build Rails Apps 10x Faster

by Adrian Marin

The video titled "Build Rails Apps 10x Faster" features Adrian Marin as a keynote speaker at the Euruko 2023 event. In this presentation, Adrian reflects on his experiences as a developer and introduces Avo, a tool designed to streamline the creation of business applications in Rails.

Key Points Discussed:
- Introduction and Background: Adrian introduces himself, mentioning his diverse experiences in freelancing, corporations, and startups. He highlights his transition from PHP and Node.js to Ruby on Rails, emphasizing Rails' declarative nature, which simplifies the development process.
- Common Development Challenges: The talk addresses frequent issues developers encounter when building web applications, such as duplicated efforts when adding resources and managing internal systems that often lack documentation and testing. This leads to decay and potential rewrites of systems.
- Need for a Declarative Approach for Front-End Development: Adrian questions why a declarative method for building user interfaces is often overlooked, noting existing tools like Active Admin but advocating for more flexibility and capability.
- Introduction of Avo: Avo is introduced as a solution that helps developers efficiently create CRUD applications for various business needs, ranging from CRM systems to content management. The tool is designed to integrate seamlessly with Rails applications, providing both a community and a pro version for developers.
- Key Features of Avo: Adrian highlights three main features of Avo:
- CRUD Interface: The core functionality allowing users to create, read, update, and delete entries easily.
- Dashboards: Useful for providing an overview and insights into data.
- Custom Content: Allows flexibility in cases where the DSL does not meet specific needs.
- Live Demo: Adrian conducts a live demo where he installs Avo into a Rails application, demonstrates resource creation, and showcases Avo's capabilities, including file uploads and data management. He illustrates how easy it is to set up properties with agents and manage their relationships efficiently.
- Dynamic Functionality: He explains Avo’s ability to filter, search, and provide customizable actions, enhancing user experience and productivity.
- Conclusions: The key message emphasizes the importance of utilizing community-driven tools like Avo to create maintainable and robust internal systems that can adapt to evolving business requirements. Adrian concludes by thanking the audience for their attention and involvement.

Overall, the presentation effectively demonstrates Avo's potential to improve both developer workflows and user interactions, addressing many common pitfalls in building Rails applications.

00:00:12.519 I guess I can add 'keynote speaker for Euruko 2023' on my resume now. Right, cool! Thank you so much for coming. I hope your lunch was good. Thank you so much for your votes. I feel really honored to be here on this stage.
00:00:33.520 Let's get into it. My name is Adrian, and I've worked as a freelancer in corporations and in a Silicon Valley startup. I've been part of all kinds of teams, and I’m an aspiring entrepreneur.
00:00:46.680 Currently, I host the Friendly RB conference, which is happening next week in Bucharest. I'm also the co-host of The Friendly Show with my friend Yaro. You can check it out at www.friendly.show. You'll find me as Adrian and the Dev everywhere, so I'm easy to find.
00:01:04.239 I didn't start my career with Rails or Ruby; I began with PHP, WordPress, and Laravel, along with a little bit of Node.js. At some point, someone introduced me to Rails. One thing that I noticed is that Rails is very declarative. Instead of writing what you need to do, you simply tell it what you need, and it will execute it for you.
00:01:23.079 When I started with Rails, as many people here might have, you typically use the scaffolding command. You run 'rails generate scaffold' and instantly receive a beautiful controller, a nice index view, and forms. It creates a usable user interface, and you begin building your resource page by adding features.
00:01:48.360 Then, if you want to add another resource, like users, what do you do? You run the scaffold command again, duplicating your efforts. You might find yourself copying code from one resource to another, only to discover later that it doesn't work in production because the label has changed. Copying and pasting is not the best practice, and building everything from scratch each time is not ideal.
00:02:04.519 Usually, when you begin building a product, you start small by developing a simple page. You’ll keep adding features, and at some point, when you have numerous resources, you start transferring them between projects. As engineers, we often feel the need to create abstractions to avoid repetitive tasks. For instance, you might have a search feature in Project A that you want to integrate into Project B.
00:02:28.560 However, with each project, new requirements come into play, leading you to add new options. And in the rush to deliver, documentation is often neglected, and tests aren't written. Before you know it, instead of having a single search abstraction across multiple projects, you end up with separate implementations for each project.
00:02:54.840 This is a common challenge, particularly in internal systems, where many projects decay over time due to a lack of documentation and testing. This can make onboarding newcomers difficult, especially when the original developers have left the company. As a result, internal systems deteriorate, and eventually, someone might suggest pressing the reset button, stating, 'This is not working; let’s rewrite it from scratch.'
00:03:17.959 Reflecting on this, I wondered why we don't have a similar declarative approach for building user interfaces. Why don’t we have a Domain Specific Language (DSL) for creating our front-end applications? We do have tools like Active Admin and Rails Admin, but they can be limited for users and developers.
00:03:39.640 This led me to develop Avo. Avo is a tool designed to help developers build business applications quickly. But what exactly are business applications? They are those admin panels and internal tools we all create, like Customer Relationship Management (CRM) systems or Enterprise Resource Planning (ERP) applications. They can also be customer-facing apps, such as ticketing systems or any type of content management system written in Rails.
00:03:56.319 In essence, Avo helps streamline the process of creating CRUD (Create, Read, Update, Delete) applications. If you consider it, many applications can be distilled down to CRUD functionality – take Instagram, for instance, where you have a feed, details, edit buttons, and comments, all of which are associations. Similarly, applications like Airbnb and Booking.com can also be boiled down to CRUD applications.
00:04:10.639 Avo helps developers build business applications efficiently by staying close to Rails defaults. We designed Avo to be easily understandable and approachable for contributors checking out the source code without using complex magic. We avoid monkey patching and our DSL is smart and extendable. Whenever the DSL doesn’t fulfill your needs, it doesn't obstruct you and simply reverts back to familiar Rails code.
00:04:43.120 Avo is properly tested, heavily documented, and community-driven. We have many contributors; it’s not just me behind the desk developing this product. Avo currently has two versions: a community version and a pro version. The community version will be open-sourced under LGPL, and we’re in open beta for Avo 3. Additionally, the commercial packages come with a perpetual fallback license, allowing users to continue using the latest version even if they choose not to maintain their subscription.
00:05:08.960 We already have over 130 happy customers and more than 250 applications running Avo in production. Moreover, Avo has garnered over 1.2k stars on GitHub. As a Rails engine, it's easy to integrate into your existing Rails application. It can be installed via RubyGems, meaning it can seamlessly operate within your current app.
00:05:33.920 Avo is designed to work with both existing applications and new ones. Importantly, all data stays with you. We don’t send any data to our servers; it functions independently of cloud services like Retool or Forest Admin. To summarize, Avo has three main features: the CRUD interface, dashboards, and custom content.
00:05:58.640 The CRUD interface is where most of the value lies. In fact, it accounts for approximately 70% of the value provided by Avo. Dashboards are incredibly useful too, while custom content is a broad term for everything you need to integrate when the DSL doesn't cover your requirements directly.
00:06:20.760 The way it works is that each resource maps to a model. A model can have multiple resources, and resources consist of fields. The hallmark of Avo is its philosophy: you tell it what you need, and it will execute it for you. Every resource benefits from built-in search, sorting, filters, actions, and active storage—essentially everything you might need for a new internal tool or CMS.
00:06:53.839 For example, on the left, you have a Rails model with validations and associations. On the right is a resource, which might be a post resource. It matches the post model, allowing you to set titles, search queries, and eager loading while adding fields. Avo includes about 30 built-in fields, with options ranging from simple text to advanced types like markdown.
00:07:13.960 Fields can have various properties, including cover photos, which is a straightforward integration with Active Storage to manage file uploads in just one line of code. You can also create computed fields and utilize all the associations that Rails supports, such as belongs_to, has_many, and has_and_belongs_to_many.
00:07:39.320 Now, what we’re going to do is a live demo. Imagine that we are the owners of a real estate agency in Hawaii, and we want to digitize our operations. Here’s what MidJourney created for a real estate agency in Hawaii. We’re going to keep it simple; we’ll have users (the agents of the real estate agency), properties listed, and bookings.
00:08:04.720 I need everyone to wait a moment while I set this up. Perfect! Now, let’s start with the installation process. I’m going to use this Rails application to run the demo. It is simply a standard Rails app with Devise installed, featuring only the users model and Active Storage.
00:08:24.840 If everything goes smoothly, I’ll show you how to add Avo to our application. The application is currently empty with no Avo folder or configurations set up, but we’ll add those soon. Let's start by installing Avo. I will copy a snippet from the Avo website, paste it into our app, and begin the installation process, which will add Avo to our Gemfile and configure the necessary routes.
00:08:45.679 Once the installation process is complete, I will adjust the configuration file. We need to make some housekeeping adjustments to set this to Pro and add a license. We will also be defining the current user model. Avo is designed to work flexibly with various user auth setups, but here I’ll specify that the current user method is simply 'current_user'.
00:09:07.360 After implementing these changes, let's restart the application and visit our Avo interface. Once I refresh, Avo will recognize the users model from the database and automatically generate a user resource for us. Since we currently have no users in the database, let's sign up quickly.
00:09:30.960 I'm going to select a simple password—don’t tell anyone, but it’s 'secret'! Now, let's proceed to see all the users in our database. From this interface, I can view the newly created user details, hit edit, and update the specific fields quite easily.
00:09:54.160 You might have noticed that the user representation in Avo needs a bit more context, as it’s unclear what the record should be called. Records differ—for example, posts have titles while users have names. To improve this, I will modify the user resource to specify that the representation should be the first name of the user. Now, it represents each user clearly.
00:10:20.600 Further, I can create a method in my user model that concatenates the first name and last name. I’ll go back to the user resource and use this method for a more descriptive title. What’s even better is utilizing Active Storage with Avo.
00:10:45.400 So, inside the user resource, I’ll add a photo attachment. After refreshing, I will incorporate the necessary configuration to indicate that the user model has a file attached. We can efficiently handle file upload with just a few adjustments.
00:11:12.760 Now, if I refresh the page again, Avo acknowledges that this user model has a file attached. I can edit it and choose a photo to upload seamlessly. With just a line of code, I've integrated Active Storage into our resource.
00:11:45.760 Let's now move to adding the property resource! Whenever we add a new resource, we can simply run the command 'rails generate model property'. A property will have fields such as name, address, and a reference to the user.
00:12:06.440 Once the command has been executed, Rails will create the necessary model and controller, and Avo will hook up seamlessly to create a property resource. I will refresh the Avo panel, run any pending migrations, and now we have a page ready to show properties.
00:12:41.160 Let’s add a new property! I’ll say it’s located in Kawaii, and I will assign it to an existing user. Avo smartly shows me the users associated with that property, allowing me to save it efficiently.
00:13:06.160 In addition to that, I’ll also add a photo for the property, much like we handled the user model. Active Storage handles file attachments well, and let’s take this concept further.
00:13:26.160 As I'm attaching properties, Avo will let me specify that I want to handle multiple images. I will go to the property resource and configure it to accept multiple file uploads. You can see how simple it is to manage data and how intuitive controls help streamline the process.
00:13:56.640 Now, if I refresh, I can choose several photos at once for this property and handle these files quickly through Avo's interface. It’s impressive how this can help manage property listings effectively.
00:14:21.360 Let’s take a moment to reconsider the data structure we’ve built. It’s quite effective, but permit me to reseed the data for better context. I'll ensure the properties are updated appropriately.
00:14:43.320 If everything is set perfectly, we’ll see a nice array of users along with their associated properties. You could imagine each model being fully represented with vivid details and context.
00:15:06.160 Now that we have multiple agencies, let’s prepare to dive into more complex use cases. For instance, how about allowing users to attach properties to only certain agents while limiting access to the rest?
00:15:32.960 This logic can come into play, making use of associations and ensuring that users can only select properties assigned to them. This involves using scopes in Avo, where we can define more intricate relationships and permissions.
00:15:54.960 In Avo, the first block allows for powerful customization options that can be tailored to specific business needs. This flexibility can enhance user experience as you can filter based on various contracts and requirements.
00:16:22.040 Imagine being able to show properties based only on starting letters or any other criteria. With Avo, that’s straightforward and easily achievable using Active Record queries.
00:16:42.640 Also, for users with multiple properties, you want dynamic visibility to the records showing only those fulfilling certain conditions. Through Avo's built-in capabilities, this can be executed quite seamlessly.
00:17:04.000 Furthermore, Avo offers you the means to add additional filters and search capabilities effectively. You can enable users to search a particular resource directly within the interface or even enable global searches if needed.
00:17:21.560 Avo does an incredible job of facilitating complex queries while maintaining a user-friendly interface. Again, callbacks and events can be customized, allowing for even more dynamic interactions with the data models.
00:17:39.320 And, of course, sorting capabilities are provided seamlessly. You can simply mark any field as sortable and refresh your display to see it in action, accommodating user needs with ease.
00:17:55.320 Creating complex filters is straightforward. Imagine generating an agent filter where you can view only those agents assigned specific roles in the organization; those filters will allow you to declutter your searches effectively.
00:18:13.760 In Avo, defining filter scopes provides further granularity, allowing you to manage data retrieval based on defined user permissions or property characteristics.
00:18:37.440 Initiating actions on records, such as marking booked properties as 'visited', introduces yet another layer of functionality that your admins or users can utilize for efficient property management.
00:18:57.200 The actions are simple to generate. By defining custom actions, users can invoke functionalities directly from the interface, making it efficient to manage statuses and ensure properties are tracked.
00:19:18.720 As we sum this up, it’s remarkable to see how simple integrations can vastly improve the developer and user experiences. Avo’s well-designed features promote productivity while allowing deep customization.
00:19:39.320 The key takeaway from this presentation is that internal systems often lack proper documentation, updates, and testing. Typically, these systems decay, leading to repeated rewrites.
00:20:00.920 So, leveraging community-driven tools like Avo is essential to maintaining robust systems that can evolve efficiently with business demands.
00:20:11.560 Thank you so much!