<?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: Augusto Queirantes</title>
    <description>The latest articles on DEV Community by Augusto Queirantes (@augusto_queirantes).</description>
    <link>https://dev.to/augusto_queirantes</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%2F169772%2F7f38d078-85fa-4c92-a1a7-01c29e4102a8.jpg</url>
      <title>DEV Community: Augusto Queirantes</title>
      <link>https://dev.to/augusto_queirantes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/augusto_queirantes"/>
    <language>en</language>
    <item>
      <title>Tudo que você precisa saber sobre DynamoDB - Introdução</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Wed, 03 Jan 2024 02:10:04 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/tudo-que-voce-precisa-saber-sobre-dynamodb-introducao-di9</link>
      <guid>https://dev.to/augusto_queirantes/tudo-que-voce-precisa-saber-sobre-dynamodb-introducao-di9</guid>
      <description>&lt;h1&gt;
  
  
  O que é DynamoDB
&lt;/h1&gt;

&lt;p&gt;DynamoDB é um banco de dados não relacional totalmente gerenciado pela AWS. Isso significa que, você não precisará ter preocupações relacionadas à escalabilidade e disponibilidade do seu banco de dados. A AWS assume a responsabilidade por esses aspectos, permitindo que você se concentre exclusivamente nas necessidades específicas do seu sistema.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conceitos básicos
&lt;/h1&gt;

&lt;p&gt;O DynamoDB armazena dados em uma estrutura de documentos, que são salvos como JSON, proporcionando flexibilidade na adição de novos campos conforme necessário.&lt;/p&gt;

&lt;p&gt;Para indexar os registros, o DynamoDB utiliza uma combinação de &lt;code&gt;partition_key&lt;/code&gt; e &lt;code&gt;sort_key&lt;/code&gt;. A partition_key define um atributo usado para separar itens, agrupando itens com a mesma chave de partição. Essa chave também é conhecida como primary_key ou HASH. Já a sort_key é um atributo opcional usado para ordenar itens que compartilham a mesma chave de partição, também chamada de RANGE ou range key.&lt;/p&gt;

&lt;h1&gt;
  
  
  Consistência de leitura
&lt;/h1&gt;

&lt;p&gt;O DynamoDB armazena três réplicas da sua base de dados em regiões geograficamente distintas. Para garantir que, ao realizar uma leitura, você obtenha a versão mais atual dos dados, o DynamoDB oferece dois níveis de consistência de leitura: consistência eventual e consistência forte.&lt;/p&gt;

&lt;p&gt;Operações realizadas com consistência eventual permitem que consultas retornem dados que ainda não foram totalmente propagados para todas as regiões; em contrapartida, esse modo oferece uma latência menor. Por outro lado, operações realizadas sob o regime de consistência forte garantem que os dados lidos sejam os mesmos em todas as regiões, embora a latência dessas operações seja maior.&lt;/p&gt;

&lt;p&gt;A escolha entre esses níveis de consistência é muito importante e deve ser feita levando em consideração as especificidades da sua aplicação.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusão
&lt;/h1&gt;

&lt;p&gt;Em resumo, o DynamoDB destaca-se como uma ótima ferramenta que resolve muito bem os problemas que se propõe.&lt;/p&gt;

&lt;p&gt;Nos próximos artigos, continuaremos desbravando as fascinantes possibilidades que o DynamoDB proporciona.&lt;/p&gt;

&lt;p&gt;Agradeço por fazer parte desta jornada. Até o próximo artigo!&lt;/p&gt;

</description>
      <category>braziliandevs</category>
      <category>webdev</category>
      <category>nosql</category>
      <category>aws</category>
    </item>
    <item>
      <title>Learning GO - Creating the server - Part 2</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Thu, 13 Oct 2022 14:35:03 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/learning-go-creating-the-server-part-2-4kga</link>
      <guid>https://dev.to/augusto_queirantes/learning-go-creating-the-server-part-2-4kga</guid>
      <description>&lt;p&gt;Hey guys! How are you? Hope everyone is ok!&lt;/p&gt;

&lt;p&gt;This is the second part of a series of articles that will document my process of learning Go. In the past article we created a working environment and executed a hello world. In this article we'll configure a web server to see it working in a browser.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of content
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Go package managers&lt;/li&gt;
&lt;li&gt;Configuring the webserver&lt;/li&gt;
&lt;li&gt;Creating the routes&lt;/li&gt;
&lt;li&gt;
Creating the controllers
-- sad&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Go package managers
&lt;/h1&gt;

&lt;p&gt;A package manager is a way to versionate the dependencies you want inside your application, that's the same as rails gems or npm packages.&lt;/p&gt;

&lt;p&gt;To configure it we gonna execute the following commands inside the docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init
go mod init github.com/your_user/your_repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can execute any of the above commands, the difference is the module name, if you set your github repo as an argument this will be the module name, otherwise the module name will be &lt;code&gt;app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After run the command you should see somehting like this as output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fwa93f317jvetau6dbi7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fwa93f317jvetau6dbi7d.png" alt="Image description" width="663" height="72"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring the webserver
&lt;/h1&gt;

&lt;p&gt;To create the webserver we gonna use a lib called &lt;a href="https://github.com/gin-gonic/gin#installation" rel="noopener noreferrer"&gt;gin&lt;/a&gt;, that's how we gonna configure it:&lt;/p&gt;

&lt;p&gt;The first thing to do is download the lib, to do this we gonna execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go get -u github.com/gin-gonic/gin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it's installed we need to import it on our main file, that's how it should looks like in the end of the day:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"net/http"&lt;/span&gt;
  &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;webserver&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="n"&gt;webserver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Hello, world!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;webserver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":3000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You probably noticed that we had some changes in this file, they were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change imports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We didnt's needed to import &lt;code&gt;fmt&lt;/code&gt; package anymore cause we don't wanna the &lt;code&gt;print&lt;/code&gt; function, so we removed it. Now we just import gin and net/http&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Refactor on main function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We completly refactored the main function, now it creates a webserver that has only one route that responds with a json. After creating this webserver we run this server on port 3000&lt;/p&gt;

&lt;p&gt;If everything is ok you should see something like this when you access &lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;this route&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7lp6uhb003i0yy6et13i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7lp6uhb003i0yy6et13i.png" alt="Image description" width="252" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating the routes
&lt;/h1&gt;

&lt;p&gt;You may noticed that we have only one route on our application, that's a problem because I want to have as many routes as I can inside of a separeted file. To do this we gonna follow this proccess:&lt;/p&gt;

&lt;p&gt;The first thing to do is create a file called &lt;code&gt;server.go&lt;/code&gt; inside &lt;code&gt;config&lt;/code&gt; folder, this file will contain our routes and execute them, that how it should look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;

  &lt;span class="s"&gt;"github.com/your_user/your_repo/controllers"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;router&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HomeIndex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/message/:message"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ShowMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":3000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code imports gin and controllers (we'll talk about it soon) and has only one method, called &lt;code&gt;Server&lt;/code&gt;, this method contains all routes and execute them in the end of the method, that's pretty much the same code that we have in our main.&lt;/p&gt;

&lt;p&gt;You may noticed that when we create a route we gives the route's path as first argument and call a method as second argument, this method is instantiated in a controller and will everything we want this route to do.&lt;/p&gt;

&lt;p&gt;For test purposes we'll create two routes, &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;/message&lt;/code&gt;. The &lt;code&gt;/&lt;/code&gt; route will always return &lt;code&gt;Hello world&lt;/code&gt; and &lt;code&gt;/message&lt;/code&gt; route will return a string that's given as parameter in the path.&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating the controllers
&lt;/h1&gt;

&lt;p&gt;To respond to a route we'll use a controller, to create the controllers we'll need in this example follow this steps:&lt;/p&gt;

&lt;p&gt;We'll need to create two files, &lt;code&gt;controllers/homeController.go&lt;/code&gt; and &lt;code&gt;controllerrs/messageController.go&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The home controller will have the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;controllers&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"net/http"&lt;/span&gt;
  &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;HomeIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code just returns a json with the expected message, that's the same code we have in our main right now&lt;/p&gt;

&lt;p&gt;The message controller will have the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;controllers&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"net/http"&lt;/span&gt;
  &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;ShowMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code has the same structure with only one addition, it gets a params from the url and return it in the json.&lt;/p&gt;

&lt;p&gt;Now we just need to change our main file to get everything working together, that's how it should looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"github.com/your_user/your_repo/config"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The changes we made now is to import only the config folder and call the &lt;code&gt;Server&lt;/code&gt; method we created before.&lt;/p&gt;

&lt;p&gt;If everything is ok you should see something like this when execute &lt;code&gt;go run main.go&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;If you access &lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;home&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fwvwhz2sej6i28x9mmtau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fwvwhz2sej6i28x9mmtau.png" alt="Image description" width="248" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you access &lt;a href="http://localhost:3000/message/test" rel="noopener noreferrer"&gt;message&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm3u5sec4g1qrq8s2d5tu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm3u5sec4g1qrq8s2d5tu.png" alt="Image description" width="332" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that the API returns &lt;code&gt;test&lt;/code&gt; cause that's the argument we're giving, you can test it and see the result changing.&lt;/p&gt;

&lt;p&gt;We'll guys, that's it! If there is any questions leave a comment! You can find the full code &lt;a href="https://github.com/augusto-queirantes/learning_go/pull/1" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Learning GO - Creating the environment using docker - Part 1</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Wed, 12 Oct 2022 08:24:53 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/learning-go-creating-the-environment-using-docker-part-1-id2</link>
      <guid>https://dev.to/augusto_queirantes/learning-go-creating-the-environment-using-docker-part-1-id2</guid>
      <description>&lt;p&gt;Hey guys! How are you? Hope everyone is ok!&lt;/p&gt;

&lt;p&gt;I'm a Rails developer that wants to learn Go and document the process on this series of articles. It's worth mentioning that I'm learning this technology, so, suggestions are welcome :)&lt;/p&gt;

&lt;p&gt;In this article I'll setup docker and test it with a hello world!&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of Content
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Setting up Docker&lt;/li&gt;
&lt;li&gt;Creating hello world&lt;/li&gt;
&lt;li&gt;Creating Github repository&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up Docker
&lt;/h1&gt;

&lt;p&gt;The first thing we need to do is create a folder to the repo, you can use the command bellow to create the folder and go to that directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir learning_go
cd learning_go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will create a new folder called &lt;code&gt;learning_go&lt;/code&gt;. All changes we gonna do will be in this folder.&lt;/p&gt;

&lt;p&gt;Once the folder is created we need to create two files: &lt;code&gt;Dockerfile&lt;/code&gt; and &lt;code&gt;docker-compose.yml&lt;/code&gt;. You can use the following command to create this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch Dockerfile
touch docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the file is created you'll need to open the folder inside your favorite text editor.&lt;/p&gt;

&lt;p&gt;The Dockerfile content will be the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM golang:1.19.2-alpine3.16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the only line you'll gonna need on this file. It tells docker to download a image that is built based on alpine linux and runs go version 1.19.2.&lt;/p&gt;

&lt;p&gt;Now we need to edit &lt;code&gt;docker-compose.yml&lt;/code&gt;, that's the file content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.9'

services:
  learning_go:
    container_name: learning_go
    build: .
    volumes:
      - ./:/go/src/app
    ports:
      - "3000:3000"
    working_dir: /go/src/app
    tty: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once everything is done you need to run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is ok you should see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fov1hs8l5oxa49nxdo7go.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fov1hs8l5oxa49nxdo7go.png" alt="Image description" width="570" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to execute commands inside the docker container you must run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it learning_go sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Creating hello world
&lt;/h1&gt;

&lt;p&gt;Now that docker is running as expected we need to create a go file to test it, so we gonna create a file called &lt;code&gt;main.go&lt;/code&gt; in the root path of the application and set this content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    fmt.Println("hello world!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code is only a basic hello world example. To execute this code you need to run the following command inside the docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flpiuisjpp638r0th3o8n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flpiuisjpp638r0th3o8n.png" alt="Image description" width="314" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating Github repository
&lt;/h1&gt;

&lt;p&gt;Now that everything is working we need to store the code in a github repository. To do so you just need to access &lt;a href="https://github.com/new" rel="noopener noreferrer"&gt;this url&lt;/a&gt; and set the repo name such as the image bellow&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fqenybovzkfc50v0luveq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fqenybovzkfc50v0luveq.png" alt="Image description" width="744" height="926"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once it's done you just need to follow the instruction that github provides:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1wsjlr5vczpdvw3mvm5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1wsjlr5vczpdvw3mvm5e.png" alt="Image description" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Well guys, that's it! Thanks for your attention! Let me know if there is any questions that I can help. You can find this project repository &lt;a href="https://github.com/augusto-queirantes/learning_go" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rails guide - Project patterns - Part 6</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Sun, 09 Oct 2022 07:02:54 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-project-patterns-part-6-4mm3</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-project-patterns-part-6-4mm3</guid>
      <description>&lt;p&gt;Hey guys! How are you?&lt;/p&gt;

&lt;p&gt;This article is a part of a series that will teach how to create a production ready rails application. In this article we gonna talk about project patterns and how we'll organize our project.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of content
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Rails way to do things&lt;/li&gt;
&lt;li&gt;Project patterns&lt;/li&gt;
&lt;li&gt;Project tree&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Rails way to do things
&lt;/h1&gt;

&lt;p&gt;Rails is a framework known by their conventions, you can find the following quote in &lt;a href="https://guides.rubyonrails.org/getting_started.html#what-is-rails-questionmark" rel="noopener noreferrer"&gt;Rails official documentation&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This quote clearly says that we need to organize our software in a way that respects Rails standards, so, that's how we gonna do this:&lt;/p&gt;

&lt;h1&gt;
  
  
  Project patterns
&lt;/h1&gt;

&lt;p&gt;We gonna organize our software following these principles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Controllers will have no logic, it'll either validate parameters or call another class&lt;/li&gt;
&lt;li&gt;Services will interact with thirdy party services&lt;/li&gt;
&lt;li&gt;UseCases will create data into our database and interact with our models&lt;/li&gt;
&lt;li&gt;Models will store application logic&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you already read about &lt;a href="https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html" rel="noopener noreferrer"&gt;Clean Architecture&lt;/a&gt; probably noticed that the project structure follows the ideia that pattern suggests.&lt;/p&gt;

&lt;h1&gt;
  
  
  Folder organization
&lt;/h1&gt;

&lt;p&gt;In the end of the day, we'll use mostly the following folders in our project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- app
-- controllers
-- models
-- services
-- use_cases
- lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;controller&lt;/code&gt; folder is our interface to the web, that's where we'll define our routes actions.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;models&lt;/code&gt; folder is where we define our entities and some business logic.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;services&lt;/code&gt; folder is our interface to third party applications, such as external apis.&lt;/p&gt;

&lt;p&gt;The use_cases folder is our interface to our entities.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;lib&lt;/code&gt; folder will contain all code that's not directly related to our project core, such as parsers.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I hope everyone understood why we gonna organize the project using this method, please comment if there is any questions.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>architecture</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Rails guide - Adding CI - Part 5</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Sun, 25 Sep 2022 02:15:50 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-adding-ci-part-5-3dc4</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-adding-ci-part-5-3dc4</guid>
      <description>&lt;p&gt;Hey guys! How are you?&lt;/p&gt;

&lt;p&gt;This article is a part of a series that will teach how to create a production ready rails application. Today we're gonna talk about CI.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of content
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;What is CI&lt;/li&gt;
&lt;li&gt;Tooling&lt;/li&gt;
&lt;li&gt;Action creation&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What is CI
&lt;/h1&gt;

&lt;p&gt;CI, ou integração contínua, é uma metodologia que visa automatizar o processo de execução de testes e linting para cada alteração de código feita, garantindo assim mais qualidade e segurança no processo&lt;/p&gt;

&lt;p&gt;CI, or continuous integration, is a methodology that automates linting and tests execution after each pull request ensuring quality and security in the process.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tooling
&lt;/h1&gt;

&lt;p&gt;The tool we'll use to solve this problem is [Github actions[(&lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;https://github.com/features/actions&lt;/a&gt;). This tool allow us to automate the tests and linting execution after any commit on a pull request.&lt;/p&gt;

&lt;h1&gt;
  
  
  Action creation
&lt;/h1&gt;

&lt;p&gt;To create the github action we gonna work on &lt;code&gt;.github/workflows&lt;/code&gt; path, all files related to a action goes here.&lt;/p&gt;

&lt;p&gt;First thing to do is create a file called &lt;code&gt;linter.yml&lt;/code&gt; with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Linter

on: push

jobs:
  linting:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-ruby@v1
      - name: Install dependencies
        run: bundle install
      - name: Run linter
        run: rubocop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file will create a action called &lt;code&gt;Linter&lt;/code&gt; that have on job called &lt;code&gt;linting&lt;/code&gt;, this job will be executed in a ubuntu doker image that will perform the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pull the most recent code&lt;/li&gt;
&lt;li&gt;Install ruby on the image&lt;/li&gt;
&lt;li&gt;Install system dependencies&lt;/li&gt;
&lt;li&gt;Install gems&lt;/li&gt;
&lt;li&gt;Execute linter&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that linter is configured we gonna create a file called &lt;code&gt;tests.yml&lt;/code&gt; to configure tests action, here the file content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Tests

on: push

jobs:
  specs:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres
        env:
          POSTGRES_USER: user
          POSTGRES_PASSWORD: 123456
        options: &amp;gt;-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v1

      - uses: actions/setup-ruby@v1
        with:
          bundler-cache: true

      - name: Install dependencies
        run: sudo apt-get install libpq-dev

      - name: Install dependencies
        run: |
          sudo apt-get -yqq install libpq-dev
          gem install bundler
          bundle install --jobs 4 --retry 3

      - name: Database setup
        run: |
          bundle exec rake db:create
          bundle exec rake db:migrate
        env:
          RAILS_ENV: test
          POSTGRES_USER: user
          POSTGRES_PASSWORD: 123456

      - name: Run specs
        run: bundle exec rspec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file will create a job called &lt;code&gt;Tests&lt;/code&gt; that will create a job called &lt;code&gt;specs&lt;/code&gt;, this job will be executed using a ubuntu docker image as base and perform the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setup postgres database&lt;/li&gt;
&lt;li&gt;Pull the most recent code&lt;/li&gt;
&lt;li&gt;Setup ruby&lt;/li&gt;
&lt;li&gt;Install dependencies&lt;/li&gt;
&lt;li&gt;Create database&lt;/li&gt;
&lt;li&gt;Run specs&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If everything is ok you should look something like this whey you open a pull request on github:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fp63o94bew3yfzusrbj7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fp63o94bew3yfzusrbj7m.png" alt="Image description" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see all code changes &lt;a href="https://github.com/augusto-queirantes/rails_guide/pull/5" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>testing</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Rails guide - Adding tests - Part 4</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Fri, 23 Sep 2022 02:54:19 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-adding-tests-part-4-3gl8</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-adding-tests-part-4-3gl8</guid>
      <description>&lt;p&gt;Hey guys! How are you?&lt;/p&gt;

&lt;p&gt;This article is a part of a series that will teach how to create a production ready rails application. Today we're gonna talk about testing with rspec.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of content
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;What is Rspec&lt;/li&gt;
&lt;li&gt;Setting up environment&lt;/li&gt;
&lt;li&gt;Configuring Rspec&lt;/li&gt;
&lt;li&gt;Test it out&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What is Rspec
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://rspec.info/" rel="noopener noreferrer"&gt;Rspec&lt;/a&gt; is a ruby gem that allow us to test our applications, it provides the best way to do TDD while developing new features.&lt;/p&gt;

&lt;h1&gt;
  
  
  Setting up environment
&lt;/h1&gt;

&lt;p&gt;We need to follow those instructions to get rspec working:&lt;/p&gt;

&lt;h3&gt;
  
  
  Install the gems
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;group&lt;/span&gt; &lt;span class="ss"&gt;:test&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="c1"&gt;# Rspec&lt;/span&gt;
  &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s2"&gt;"rspec-rails"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 5.1.2"&lt;/span&gt;

  &lt;span class="c1"&gt;# Fake data generator&lt;/span&gt;
  &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s2"&gt;"faker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 2.23.0"&lt;/span&gt;

  &lt;span class="c1"&gt;# Clean database before each test execution&lt;/span&gt;
  &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s2"&gt;"database_cleaner-active_record"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 2.0.1"&lt;/span&gt;

  &lt;span class="c1"&gt;# Factories&lt;/span&gt;
  &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s2"&gt;"factory_bot_rails"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 6.2.0"&lt;/span&gt;

  &lt;span class="c1"&gt;# Models specs&lt;/span&gt;
  &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s2"&gt;"shoulda-matchers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 5.1.0"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Download the dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bundle &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Generate Rspec configuration files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rails generate rspec:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Require rails helper
&lt;/h3&gt;

&lt;p&gt;To properly run specs we need to require rails helper on top of each spec file, to prevent this we can create a file called &lt;code&gt;.rspec&lt;/code&gt; in the root path of the application and put the following content there:&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="nt"&gt;--require&lt;/span&gt; rails_helper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Configuring Rspec
&lt;/h1&gt;

&lt;p&gt;Now that we have all the setup done we need to properly configure rspec, to do so we need to edit &lt;code&gt;rails_helper&lt;/code&gt; and &lt;code&gt;spec_helper&lt;/code&gt;. You'll find the full code snippet in a pull request in the end of the article, nut here's a quick explanation of some important points:&lt;/p&gt;

&lt;h3&gt;
  
  
  Rails Helper
&lt;/h3&gt;

&lt;p&gt;This file stores all rspec general configuration and some dependencies configurations such as factory_bot and shoulda_matchers. Another important thing is that on the top of the file we have a guard clause that prevents rspec to run in a environemnt different thant test, you should never remove this safe guard&lt;/p&gt;

&lt;h3&gt;
  
  
  Spec Helper
&lt;/h3&gt;

&lt;p&gt;This file is simpler, it contains only some inclusions and basic setup, rails_helper requires this file to improve it configuration&lt;/p&gt;

&lt;h1&gt;
  
  
  Test it out
&lt;/h1&gt;

&lt;p&gt;Now that everything should be ok lets test it out. To do so we need to create a spec file and verify if it's passing.&lt;/p&gt;

&lt;p&gt;Create a file under the &lt;code&gt;spec&lt;/code&gt; folder called &lt;code&gt;test_spec.rb&lt;/code&gt; and put the following content there:&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="no"&gt;RSpec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;describe&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;describe&lt;/span&gt; &lt;span class="s2"&gt;"rspec setup"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;"returns true"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all you need to do is run rspec using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rspec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should look something like this if everything is ok:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbex22pkiglnivzvu14nu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbex22pkiglnivzvu14nu.png" alt="Image description" width="551" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can either specify somethings to this command such as the file and line it should execute, here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rspec spec/test_spec.rb
rspec spec/test_spec.rb:3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see all the code changed &lt;a href="https://github.com/augusto-queirantes/rails_guide/pull/3" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>beginners</category>
      <category>testing</category>
    </item>
    <item>
      <title>Rails guide - Adding linter - Part 3</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Sat, 17 Sep 2022 22:06:48 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-adding-linter-part-3-4nka</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-adding-linter-part-3-4nka</guid>
      <description>&lt;p&gt;Hey guys! How are you!&lt;/p&gt;

&lt;p&gt;That's the third article of a series that teaches how to create a production ready Rails application. In this article we'll configure linter.&lt;/p&gt;

&lt;p&gt;Linter is a tool that assures that all code follows the best practices defined in the project. The tool that we gonna use is called &lt;a href="https://rubocop.org/" rel="noopener noreferrer"&gt;rubocop&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Configurin rubocop
&lt;/h1&gt;

&lt;p&gt;First thing to do is add this gem to the application gemfile, to do so just add the following line in your &lt;code&gt;Gemfile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem "rubocop", "~&amp;gt; 1.36.0", require: false
gem "rubocop-rails", "~&amp;gt; 2.16.1", require: false
gem "rubocop-rspec", "~&amp;gt; 2.13.1", require: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lines will install &lt;code&gt;rubocop&lt;/code&gt; that's the main gem we'll use and &lt;code&gt;rubocop-rails&lt;/code&gt; and &lt;code&gt;rubocop-rspec&lt;/code&gt; that are dependencies of the main gem. Once you save the file, run the following command to install them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to create rubocop's configuration file, it's called &lt;code&gt;.rubocop.yml&lt;/code&gt; and need to be at the root path of the application, here it's content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require:
  - rubocop-rspec
  - rubocop-rails

AllCops:
  NewCops: enable
  Exclude:
    - 'app/assets/**/*'
    - 'app/views/**/*'
    - 'db/**/*.rb'
    - 'lib/**/*.rake'
    - 'config/**/*.rb'
    - 'bin/bundle'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use this file to ignore some checks that you don't wanna run in your application, you can see how to do it by looking in the pull request in the end of this article.&lt;/p&gt;

&lt;h1&gt;
  
  
  Testing it out
&lt;/h1&gt;

&lt;p&gt;Now that the tool is properly configured, let's test it. To run rubocop just type the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rubocop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is ok you should look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F5xasutxqt63wvjmdzyj7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5xasutxqt63wvjmdzyj7.png" alt="Image description" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's a lot of errors, but it's ok, to fix most of them you can run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rubocop -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It'll fixes all correctable issues, now just fix the rest and everything is fine&lt;/p&gt;

&lt;p&gt;You can see all the code changed &lt;a href="https://github.com/augusto-queirantes/rails_guide/pull/2" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Rails guide - Adding Docker - Part 2</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Sat, 17 Sep 2022 05:56:39 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-adding-docker-part-2-1ldk</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-adding-docker-part-2-1ldk</guid>
      <description>&lt;p&gt;Hey guys! How are you!&lt;/p&gt;

&lt;p&gt;That's the second article of a series that teaches how to create a production ready Rails application. In this article we'll configure docker and docker compose.&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring docker
&lt;/h1&gt;

&lt;p&gt;First thing we need to do is create a file called &lt;code&gt;Dockerfile&lt;/code&gt; in the root path of the application.&lt;/p&gt;

&lt;p&gt;The following snippet contains the file content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM ruby:3.1.2-alpine3.16

RUN apk --update add postgresql-dev postgresql-client build-base tzdata libxslt-dev libxml2-dev

RUN mkdir /app

WORKDIR /app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file creates a image that contains everything the application needs to run. To create this image docker follow this steps:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FROM ruby:3.1.2-alpine3.16&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This line specifies that docker should download the following image from dockerhub and use it as base to run the following commands&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RUN apk --update add postgresql-dev postgresql-client build-base tzdata libxslt-dev libxml2-dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This instruction tells to docker install the following dependencies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;build-base: To ensure certain gems can be compiled&lt;/li&gt;
&lt;li&gt;tzdata: Handle timezones&lt;/li&gt;
&lt;li&gt;libxslt-dev libxml2-dev: Nokogiri native dependencies&lt;/li&gt;
&lt;li&gt;postgresql-dev postgresql-client: Postgres related&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;RUN mkdir /app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Creates a folder called "/app"&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WORKDIR /app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tells docker that the folder "/path" is the main folder of the application.&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring docker compose
&lt;/h1&gt;

&lt;p&gt;The first thing to do to configure docker-compose is create a file called &lt;code&gt;docker-compose.yml&lt;/code&gt; in the root path of the application. This file should have the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.9'

services:
  postgres:
    image: postgres:14.5-alpine
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: 123456
      PGDATA: /data/postgres
    volumes:
      - postgres:/data/postgres
    ports:
      - "5432:5432"
    networks:
      - postgres

  rails_guide:
    build: .
    volumes:
      - .:/app
    image: rails_guide
    container_name: rails_guide
    tty: true
    ports:
      - "3000:3000"
    environment:
      - DATABASE_NAME=app_development
      - DATABASE_USERNAME=user
      - DATABASE_PASSWORD=123456
      - DATABASE_HOST=postgres
    depends_on:
      - postgres
    networks:
      - postgres

networks:
  postgres:
    driver: bridge

volumes:
  postgres:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Executing docker
&lt;/h1&gt;

&lt;p&gt;Now that everything is configured run the following command to create the containers:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker-compose up -d&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command will create both containers and get it running&lt;/p&gt;

&lt;p&gt;You can verify if everything is ok by running the following commando&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The output should looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F2ln5yte0s6pec5oi5uwf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F2ln5yte0s6pec5oi5uwf.png" alt="Image description" width="800" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now run this command to go inside the container:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker exec -it rails_guide sh&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Setting up the database
&lt;/h1&gt;

&lt;p&gt;You'll need to update the database configuration to mathces the docker environment, you'll need to change &lt;code&gt;config/database.yml&lt;/code&gt; with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default: &amp;amp;default
  adapter: postgresql
  encoding: unicode
  pool: &amp;lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&amp;gt;
  host: &amp;lt;%= ENV.fetch("DATABASE_HOST", "localhost") %&amp;gt;
  user: &amp;lt;%= ENV.fetch("DATABASE_USERNAME", "user") %&amp;gt;
  password: &amp;lt;%= ENV.fetch("DATABASE_PASSWORD", "123456") %&amp;gt;

development:
  &amp;lt;&amp;lt;: *default
  database: app_development

test:
  &amp;lt;&amp;lt;: *default
  database: app_test

production:
  &amp;lt;&amp;lt;: *default
  database: &amp;lt;%= ENV.fetch("DATABASE_NAME", "app_production") %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To setup the database you'll need to run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails db:drop
rails db:create
rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Running the server
&lt;/h1&gt;

&lt;p&gt;You can verify if everything is ok by starting the server by running the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails s -b 0.0.0.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If everything is ok you'll see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F0p9p8jauq3avbfukyaj1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F0p9p8jauq3avbfukyaj1.png" alt="Image description" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see all code changes &lt;a href="https://github.com/augusto-queirantes/rails_guide/pull/1" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>docker</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Rails guide - Creating the app - Part 1</title>
      <dc:creator>Augusto Queirantes</dc:creator>
      <pubDate>Sat, 20 Aug 2022 23:34:41 +0000</pubDate>
      <link>https://dev.to/augusto_queirantes/rails-guide-creating-the-app-part-1-4chb</link>
      <guid>https://dev.to/augusto_queirantes/rails-guide-creating-the-app-part-1-4chb</guid>
      <description>&lt;p&gt;Hey guys! How are you?&lt;/p&gt;

&lt;p&gt;That's the first article of a series that'll teach how to create a production ready Rails application. In this article we'll install Ruby, Rails and create the application.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing dependencies
&lt;/h1&gt;

&lt;p&gt;The first thing to do is install Ruby and Rails, to do that we'll use a tool called &lt;a href="https://rvm.io" rel="noopener noreferrer"&gt;RVM&lt;/a&gt;, it's used to install and manage different versions of Ruby.&lt;/p&gt;

&lt;p&gt;Execute the command bellow to install Ruby and Rails latest versions:&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="se"&gt;\c&lt;/span&gt;url &lt;span class="nt"&gt;-sSL&lt;/span&gt; https://get.rvm.io | bash &lt;span class="nt"&gt;-s&lt;/span&gt; stable &lt;span class="nt"&gt;--rails&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can verify if everything is ok running this two commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ruby &lt;span class="nt"&gt;--version&lt;/span&gt;
rails &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F8puq5y3j073p4ktq8w7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F8puq5y3j073p4ktq8w7q.png" alt="Ruby and Rails versions" width="548" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating the project
&lt;/h1&gt;

&lt;p&gt;Run the following command to create the application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rails new rails_application &lt;span class="nt"&gt;--api&lt;/span&gt; &lt;span class="nt"&gt;--adapter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgresql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that the application is created we need to go to its directory using this command:&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="nb"&gt;cd &lt;/span&gt;rails_application
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Testing it out
&lt;/h1&gt;

&lt;p&gt;The next step is test the application, to do so you'll need to run the server using the above command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rails s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is ok you should be able to see somehting like this when you access &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fodq5n6gy6of4nmodgjln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fodq5n6gy6of4nmodgjln.png" alt="Rails home screen" width="800" height="316"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;That's it, guys! See you soon in the next part. You can find the code &lt;a href="https://github.com/augusto-queirantes/rails_guide" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
