<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Takaharu Yamamoto</title>
    <description>The latest articles on DEV Community by Takaharu Yamamoto (@yamataka22).</description>
    <link>https://dev.to/yamataka22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F985149%2F5136371d-a39d-4544-9845-b3a7a3212106.png</url>
      <title>DEV Community: Takaharu Yamamoto</title>
      <link>https://dev.to/yamataka22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yamataka22"/>
    <language>en</language>
    <item>
      <title>Build an Admin Panel Fast with Rails7 and Infold</title>
      <dc:creator>Takaharu Yamamoto</dc:creator>
      <pubDate>Thu, 08 Dec 2022 04:18:39 +0000</pubDate>
      <link>https://dev.to/yamataka22/build-admin-panel-fast-with-rails7-and-infold-3og</link>
      <guid>https://dev.to/yamataka22/build-admin-panel-fast-with-rails7-and-infold-3og</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Rails engineers, what do you do when creating an admin panel or internal tool?&lt;br&gt;
One way is to use a RubyGem such as ActiveAdmin, but I’ve encountered a few problems with this approach.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's hard to customize with DSL.&lt;/li&gt;
&lt;li&gt;Sometimes I can’t achieve the required functionality.&lt;/li&gt;
&lt;li&gt;The design isn’t to my liking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For these reasons, I didn’t use an existing Gem but built it from scratch. However, even though doing that every time was inefficient, it was worth the effort because many elements of the internal tool’s features can be shared.&lt;/p&gt;

&lt;p&gt;The good news is I’ve now solved the inefficiency problem and so streamlined development by creating my own framework. And it’s improved my productivity so dramatically that I wanted to share it with you by turning the framework into a Gem and releasing it publicly.&lt;/p&gt;

&lt;p&gt;So I’m now going to show you how to use the Gem &lt;a href="https://github.com/yamataka22/infold" rel="noopener noreferrer"&gt;Infold&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Demo Site
&lt;/h3&gt;

&lt;p&gt;First off, take a look at the &lt;a href="https://demo.infold.dev/admin" rel="noopener noreferrer"&gt;demo site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This application is built using only functions automatically generated by the Gem.&lt;/p&gt;
&lt;h2&gt;
  
  
  Tool Features
&lt;/h2&gt;

&lt;p&gt;The tool has the following advantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Automatic code generation&lt;/li&gt;
&lt;li&gt;No DSL&lt;/li&gt;
&lt;li&gt;Modern, easy-to-use UI/UX&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  1. Automatic code generation
&lt;/h3&gt;

&lt;p&gt;However, it is not in AI format like GitHub Copilot but an extension of Rails' Scaffold.&lt;/p&gt;

&lt;p&gt;As you know, Rails scaffold automatically generates code such as controller, model, view, etc., and automatically create the basic functionality that enables CRUD. I’ve exploited this mechanism to develop a specialized generator for the admin panel.&lt;/p&gt;

&lt;p&gt;In addition, the generated code is designed to be readable. My aim isn’t just to make code that works but also to make the code easy for developers to read and customize for their own needs.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. No DSL
&lt;/h3&gt;

&lt;p&gt;YAML is used instead of DSL for configuration. When the YAML loads into the generator, it automatically generates the CRUD app according to the configuration.&lt;/p&gt;

&lt;p&gt;Although YAML doesn’t let you write DSL-like logic, it does enable general configuration. I think it’s better to automatically generate code up to a level that can be shared without difficulty. The code can then be customized just like in normal Rails development instead of using the DSL to realize all functions. So I’ve created a system that automatically generates code.&lt;/p&gt;

&lt;p&gt;However, even with just the YAML settings, you can generate a variety of functions. For example, as implemented in the demo site, the following functionality is available:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bulk registration and reference of &lt;code&gt;has_many&lt;/code&gt; association&lt;/li&gt;
&lt;li&gt;Validation, Enum, Decorator, and other mechanisms&lt;/li&gt;
&lt;li&gt;Image file registration, CSV file output, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  3. Modern, easy-to-use UI/UX
&lt;/h3&gt;

&lt;p&gt;Hotwire is used to let you create a SPA-like UI/UX. In addition, Tabler, which is based on Bootstrap 5, is used for the UI template. This lets you create a modern, high-usability design.&lt;/p&gt;

&lt;p&gt;Generally, designers aren’t involved in creating admin panels—not even the UI.  My aim is to enable developers who aren’t proficient in design to create usable admin panels.&lt;/p&gt;
&lt;h2&gt;
  
  
  Supported Rails versions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Infold requires Rails 7.0 or later as it’s intended to work with Hotwire.&lt;/li&gt;
&lt;li&gt;Rails requires a JavaScript bundler such as esbuild.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;I’ll now explain the process from installation to actual customization.&lt;/p&gt;
&lt;h3&gt;
  
  
  Install Infold
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;infold&lt;/code&gt; and the various gems used in Infold to the Gemfile and &lt;code&gt;bundle install&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Gemfile&lt;/span&gt;

&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'infold'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;require: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'devise'&lt;/span&gt;           &lt;span class="c1"&gt;# Certification&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'haml-rails'&lt;/span&gt;       &lt;span class="c1"&gt;# HAML&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'kaminari'&lt;/span&gt;         &lt;span class="c1"&gt;# Pagination&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'view_component'&lt;/span&gt;   &lt;span class="c1"&gt;# View Component&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'active_decorator'&lt;/span&gt; &lt;span class="c1"&gt;# Decoration&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'enum_help'&lt;/span&gt;        &lt;span class="c1"&gt;# Enum Helpers&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, install from the Infold generator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rails g infold:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you do this, common files used by view_component, stimulus, and so on will be generated.&lt;/p&gt;

&lt;p&gt;Similarly, Devise migrations will also be generated. After you’ve run the migration, set up a test account from the Rails console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rails db:migrate
&lt;span class="nv"&gt;$ &lt;/span&gt;rails console

AdminUser.create&lt;span class="o"&gt;(&lt;/span&gt;email: &lt;span class="s1"&gt;'user@example.com'&lt;/span&gt;, password: &lt;span class="s1"&gt;'password'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start Rails from &lt;code&gt;bin/dev&lt;/code&gt;, access &lt;code&gt;http://localhost:3000/admin&lt;/code&gt; with your browser, and log in to the account you set up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9cf9nxy9yfhresz0wuo5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9cf9nxy9yfhresz0wuo5.png" alt="Screen generated by infold"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The login function has now been created. Continue to build the application.&lt;/p&gt;

&lt;p&gt;In the following tutorial, you’ll create customer, product, and order management apps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a customer management app
&lt;/h3&gt;

&lt;p&gt;First, create a customer model. Here you’ll use the standard Rails generate model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g model Customer name:string address:string gender:integer
&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use Infold’s generator to create an app for this model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Customer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is all you need to generate the customer management app. Access &lt;code&gt;localhost:3000/admin/customers&lt;/code&gt; from your browser to run the app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbmyl0rhhez3424tbsfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbmyl0rhhez3424tbsfq.png" alt="Customer management app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bring up the form by clicking the orange "Create New" button. After you’ve filled the form out, click the "Create" button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllgqtzdu297117xs4sn4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllgqtzdu297117xs4sn4.png" alt="Customer registration view"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The note icon on the left of the list displays the reference view; the pencil icon on the right displays the edit view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphq6k9q5mpu3gd6zscb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphq6k9q5mpu3gd6zscb8.png" alt="Customer detail view"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In just a few steps, you were able to generate a CRUD-based admin panel app.&lt;/p&gt;

&lt;p&gt;At this point, files such as Controller and View are automatically generated. For example, &lt;code&gt;app/controllers/admin/customer_controller.rb&lt;/code&gt; is generated as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiz4dmwnfq4e7i4a19b18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiz4dmwnfq4e7i4a19b18.png" alt="Code generated from infold"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thus, &lt;strong&gt;Infold isn't like ActiveAdmin in that instead of generating the app itself, it generates the source code&lt;/strong&gt;.  Also, because the code is in standard Rails, it can be easily edited by Rails developers. Customizations that cannot be achieved with the gem alone can be flexibly handled by editing the code directly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Customized customer management app
&lt;/h4&gt;

&lt;p&gt;You can customize the app generated above by configuring it in YAML. Try it out by adding the following functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set Name as a required field.&lt;/li&gt;
&lt;li&gt;Gender is an enum of male, female, and other, which are selectable with radio buttons.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you executed the generator mentioned above, &lt;code&gt;customer.yml&lt;/code&gt; is generated in the &lt;code&gt;config/infold&lt;/code&gt; directory. Change the contents of this file to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# config/infold/customer.yml&lt;/span&gt;

&lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;presence&lt;/span&gt;
  &lt;span class="na"&gt;enum&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;gender&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;male&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
      &lt;span class="na"&gt;female&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
      &lt;span class="na"&gt;other&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;form&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;name&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;address&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;gender&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;radio&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you’ve edited the YAML, run the following again to regenerate the customer management app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Customer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Validation and radio button forms are activated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpf24koe7ro4hkjb50giq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpf24koe7ro4hkjb50giq.png" alt="Validation enabled and changed to radio buttons"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a product management app
&lt;/h3&gt;

&lt;p&gt;Next, create a product management app.&lt;/p&gt;

&lt;p&gt;Rails Model Generation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g model Product title:string price:integer
&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generating apps with Infold&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Product
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access &lt;code&gt;localhost:3000/admin/products&lt;/code&gt; with your browser to run the product management app. The header menu also has PRODUCTS added.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnch9eq8j7sduqc2toljn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnch9eq8j7sduqc2toljn.png" alt="Product management app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Display of product images
&lt;/h4&gt;

&lt;p&gt;Infold supports ActiveStorage. So if, for example, you want to manage product images, &lt;code&gt;config/infold/product.yml&lt;/code&gt; should be set as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# config/infold/product.yml&lt;/span&gt;

&lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;active_storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;photo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;image&lt;/span&gt;
&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;list&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;id&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;title&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;photo&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;price&lt;/span&gt;
  &lt;span class="na"&gt;form&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;title&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;photo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;file&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;price&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note that ActiveStorage must already be installed in the project.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Generate apps with Infold.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Product
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the above settings, images can be registered from the form and will be displayed in the list too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fos7ysocxoidjoapz5n76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fos7ysocxoidjoapz5n76.png" alt="Product images can be registered"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcy6yu69paj1kl45xcv7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcy6yu69paj1kl45xcv7z.png" alt="List with images"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating an order management app
&lt;/h3&gt;

&lt;p&gt;The customer and product management apps above had a single table as a CRUD, but the following order management app will set up a relationship between customer and product.&lt;/p&gt;

&lt;p&gt;Create an order model from Rails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g model Order customer:references product:references amount:integer
&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The relationships are as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsl5jbg1m4hnpr88afxu1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsl5jbg1m4hnpr88afxu1.png" alt="ER diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generate an order management app from Infold. You can generate only YAML files by using &lt;code&gt;g infold:resource&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold:resource Order
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit &lt;code&gt;config/infold/order.yml&lt;/code&gt; as follows to set associations for order and other models.&lt;/p&gt;

&lt;p&gt;Note that the name_field in the * portion below specifies a field for the name of the record. As a result, related destination records can be displayed in that field. For example, the &lt;code&gt;Order&lt;/code&gt; model is associated with the &lt;code&gt;Customer&lt;/code&gt; model via &lt;code&gt;customer_id&lt;/code&gt;, but instead of &lt;code&gt;customer_id&lt;/code&gt;, it displays &lt;code&gt;customer.name&lt;/code&gt; on the view.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# config/infold/order.yml&lt;/span&gt;

&lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;association&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;belongs_to&lt;/span&gt;
      &lt;span class="na"&gt;name_field&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;name&lt;/span&gt; &lt;span class="c1"&gt;# *&lt;/span&gt;
    &lt;span class="na"&gt;product&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;belongs_to&lt;/span&gt;
      &lt;span class="na"&gt;name_field&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;title&lt;/span&gt; &lt;span class="c1"&gt;# *&lt;/span&gt;
&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;form&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;select&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;product&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;select&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you've edited the YAML, generate the app from Infold.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Order
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, from the registration form, the customer and product can be selected from a list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj6outj7jdnwotsilvtu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj6outj7jdnwotsilvtu.png" alt="Select association data from a list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, after you’ve registered an order, the customer and product will be displayed as links that can be clicked on for more information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8ieo5v8w9xv3b50egci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8ieo5v8w9xv3b50egci.png" alt="Browse customer data from Order management view"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bulk registration of &lt;code&gt;has_many&lt;/code&gt; association
&lt;/h3&gt;

&lt;p&gt;The current order management app allows only one product to be registered per order because the order model is directly related to the product model ( &lt;code&gt;order belongs_to product&lt;/code&gt; ). To register multiple products at the same time, add an OrderDetail model and change the modeling to  &lt;code&gt;order has_many order_details&lt;/code&gt;, &lt;code&gt;order_detail belongs_to product&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvei5lfysaxw0xeg24qh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvei5lfysaxw0xeg24qh.png" alt="ER diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next comes modifying and adding models in Rails. First, generate the following migration to remove the association between order and product.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g migration RemoveProductFromOrders product:references amount:integer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, remove the &lt;code&gt;belongs_to :product&lt;/code&gt; as it remains in the order model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;# models/order.rb
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="p"&gt;class Order &amp;lt; ApplicationRecord
&lt;/span&gt;  belongs_to :customer
&lt;span class="gd"&gt;- # Delete the following
- belongs_to :product
&lt;/span&gt;&lt;span class="p"&gt;end
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, create an &lt;code&gt;OrderDetail&lt;/code&gt; model and migrate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g model OrderDetail order:references product:references amount:integer
&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the order.yml in Infold.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;# config/infold/order.yml
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="p"&gt;model:
&lt;/span&gt;  ...
  association:
    customer:
      kind: belongs_to
      name_field: name
&lt;span class="gd"&gt;-   # Delete the following
-   product:
-     kind: belongs_to
-     name_field: title
&lt;/span&gt;&lt;span class="gi"&gt;+   # Add the following
+   order_details:
+     kind: has_many
+     dependent: destroy
+     model: # Associated models (order_details) can also be set
+       validate:
+         product: presence
+       association: # Further associations to order_details (product)
+         product:
+           kind: belongs_to
+           name_field: title
&lt;/span&gt;&lt;span class="p"&gt;app:
&lt;/span&gt;&lt;span class="gi"&gt;+ # Bulk display on detail page as well
+ show:
+   fields:
+     - id
+     - customer
+     - order_details:
+         fields:
+           - product
+           - amount
&lt;/span&gt;  form:
    fields:
      - customer:
          kind: select
&lt;span class="gd"&gt;-     # Delete the following
-     - product
-         kind: select
-      - amount
-          kind: number
&lt;/span&gt;&lt;span class="gi"&gt;+     # Add the following
+     - order_details:
+         kind: association
+         fields:
+           - product:
+               kind: select
+           - amount:
+               kind: number
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Regenerate the order management app from Infold.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Order
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The form allows bulk registration. Add rows with the ADD button and delete them with the trash icon at the right end of the row.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly0lcx90ux5qu63nmrnp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly0lcx90ux5qu63nmrnp.png" alt="Bulk registration of OrderDetail"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Search and specify associated data from a child screen
&lt;/h3&gt;

&lt;p&gt;In the current order management registration form, customers are in a drop-down list. As the number of customers increases, it becomes more and more difficult to specify the corresponding record in the list (for instance, if there are 100 customers, there’ll be 100 choices in the list, making it unusable).&lt;br&gt;
Infold lets you search and specify associated models by &lt;code&gt;belongs_to&lt;/code&gt; from a child screen. Here’s how to change from order management to specifying customers on a child screen.&lt;/p&gt;

&lt;p&gt;First, edit the YAML (customer.yml) on the customer management side to enable child screen searches for customers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;# config/infold/customer.yml
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="p"&gt;model:
&lt;/span&gt;  ...
&lt;span class="p"&gt;app:
&lt;/span&gt;  form:
    ...
&lt;span class="gi"&gt;+ # Add the following
+ association_search:
+   conditions:
+     - id:
+         sign: eq
+     - name:
+         sign: full_like
+   list:
+     fields:
+       - id
+       - name
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, edit the YAML (order.yml) on the order management side (change &lt;code&gt;kind&lt;/code&gt; from &lt;code&gt;select&lt;/code&gt; to &lt;code&gt;association_search&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;# config/infold/order.yml
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="p"&gt;model:
&lt;/span&gt;  ...
&lt;span class="p"&gt;app:
&lt;/span&gt;  form:
    fields:
      - customer:
&lt;span class="gd"&gt;-         kind: select
&lt;/span&gt;&lt;span class="gi"&gt;+         kind: association_search
&lt;/span&gt;      - order_details:
        ...         
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Regenerate apps from Infold for customer management and order management.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Customer
&lt;span class="nv"&gt;$ &lt;/span&gt;bin/rails g infold Order
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that the customer element has changed on the order management registration form screen.&lt;br&gt;
Click the blue "Search" button on this form to bring up the customer search screen on the child screen.&lt;br&gt;
Search on the child screen and click the check icon in the list to transfer the corresponding customer to the order management form.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbjrk0ijiovi9qpbgl9t.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbjrk0ijiovi9qpbgl9t.gif" alt="Search and select customer data from child screens"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Internationalization (I18n)
&lt;/h3&gt;

&lt;p&gt;Infold supports internationalization (I18n). See the &lt;a href="https://guides.rubyonrails.org/i18n.html" rel="noopener noreferrer"&gt;Rails Guide&lt;/a&gt; and other sources for details.&lt;/p&gt;

&lt;p&gt;For example, to display Japanese(ja), create &lt;code&gt;config/initializers/locale.rb&lt;/code&gt; as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# config/initializers/locale.rb&lt;/span&gt;

&lt;span class="no"&gt;I18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;available_locales&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:ja&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:en&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="no"&gt;I18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;default_locale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;:ja&lt;/span&gt;
&lt;span class="no"&gt;I18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_path&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="no"&gt;Dir&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'config'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'locales'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'**'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'*.{rb,yml}'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, download ja.yml from &lt;a href="https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale" rel="noopener noreferrer"&gt;rails-i18n&lt;/a&gt; and put it in &lt;code&gt;config/locales&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a models directory in &lt;code&gt;config/locales&lt;/code&gt; and create &lt;code&gt;customer.ja.yml&lt;/code&gt; with the following contents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# config/locales/models/customer.ja.yml&lt;/span&gt;

&lt;span class="na"&gt;ja&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;activerecord&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;attributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;氏名&lt;/span&gt;
        &lt;span class="na"&gt;address&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;住所&lt;/span&gt;
        &lt;span class="na"&gt;gender&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;性別&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The customer management screen will be translated into Japanese.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Although the buttons and message content are also translated into Japanese, Infold itself is still only in English and Japanese.&lt;br&gt;
I’d appreciate your help in translating it into your own language!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd3hgkit7pru48x22716.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd3hgkit7pru48x22716.png" alt="Translate the application into Japanese"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When translating Enum elements, you need to plug in &lt;code&gt;admin&lt;/code&gt; as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;ja:
&lt;/span&gt;  activerecord:
    attributes:
      customer:
        name: 氏名
        address: 住所
        gender: 性別
&lt;span class="gi"&gt;+ enums:
+   admin: #  Need to plug admin
+     customer:
+       gender:
+         male: 男性
+         female: 女性
+         other: その他
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd57zvmcfi5lvybui8ctm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd57zvmcfi5lvybui8ctm.png" alt="Enum also translated into Japanese"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This has been a long tutorial, but I hope you now know how to use Infold.&lt;/p&gt;

&lt;p&gt;As you can see, it’s possible to generate a reasonable level of functionality just by using YAML settings.&lt;br&gt;
The next step is to customize the automatically generated source code.&lt;/p&gt;

&lt;p&gt;Compared to starting from scratch, I think you’ll be able to speed up implementing admin panels considerably, so I hope you’ll consider using this gem!&lt;/p&gt;

&lt;h3&gt;
  
  
  Code used in this tutorial
&lt;/h3&gt;

&lt;p&gt;The code for the app created above is in my &lt;a href="https://github.com/yamataka22/infold.demo_qiita" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>opensource</category>
      <category>admin</category>
      <category>gem</category>
    </item>
  </channel>
</rss>
