Category: 2. Hanami
-
Wrapping Up
Now that you have an overview of what Hanami 2 is all about and even created a simple app from routes all the way to the view template, we challenge you to take your learning a bit further. You will notice that we created a show route but not it’s action or the subsequent view and template…
-
Viewing the Data
Since ours is a very simple blog app, we’ll only use the view and template bits for now. Let’s start by passing the data from the relevant action into a “view”. For the blog index view, create an index.rb file under …/slices/main/lib/main/views/blog/ Here, we are telling the view that data will be passed into it via…
-
Working With Data in Hanami
As mentioned earlier, in Hanami, entities, repositories, and relations make up what we call the data layer. “Relations” define how data is fetched from the database. You would also define scopes and other database-specific queries in relations. “Repositories”, however, are database-agnostic. They mediate between entities and relations. An “entity” is where you define domain-specific logic.…
-
Overview of a Hanami 2 App Structure
Hanami really pushes the concept of abstraction or separation of concerns to the limit. If you are coming from a Rails background and it feels a bit confusing, the simplified diagram below shows you how that abstraction is done in Hanami vs. Rails. Routes The Hanami router and its Rails counterpart are generally the same.…
-
Let’s Build a Simple Hanami App
The best way to get a taste of what Hanami is all about is to roll up our sleeves and build something with it. The app we are building is a very simple blog app. Using this example, you will learn how a Hanami 2.0 app is structured. Prerequisites Before we get started, make sure…
-
What is Hanami Good For?
Depending on what you are building, you may find that a general-purpose language like Rails is a great choice. However, Hanami’s unique attributes can help you build for specific use cases, such as when you need the following: Now that we have a good idea of what the framework is about, let’s get into the…
-
Why You Should Use Hanami, and Why You Might Need (Yet) Another Ruby Framework
As we pointed out in the very beginning of this article, Hanami is just one of several Ruby frameworks. Ruby on Rails is the most popular of the Ruby frameworks. It’s very modular and general purpose. It could be said that it’s main promise is that you can use it to go from zero to having…
-
Hanami
Hanami is a Ruby framework introduced about five years ago and initially called Lotus. The framework is the brainchild of developer Luca Guidi. On the project’s website, Hanami is described as “a modern framework for Ruby”. It features fast response times and security features by default, and it is very lightweight. But even so, you may…