<?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: Engr. Promise</title>
    <description>The latest articles on DEV Community by Engr. Promise (@ukaypromise).</description>
    <link>https://dev.to/ukaypromise</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%2F687704%2Ff2a8b666-10ba-4da8-acdd-aba7142f1acd.jpeg</url>
      <title>DEV Community: Engr. Promise</title>
      <link>https://dev.to/ukaypromise</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ukaypromise"/>
    <language>en</language>
    <item>
      <title>Adding Electronic Signatures to a Rails 8 App</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Sat, 29 Mar 2025 01:10:31 +0000</pubDate>
      <link>https://dev.to/ukaypromise/adding-electronic-signatures-to-a-rails-8-app-1jdo</link>
      <guid>https://dev.to/ukaypromise/adding-electronic-signatures-to-a-rails-8-app-1jdo</guid>
      <description>&lt;p&gt;Integrating an electronic signature feature can be a great addition when building applications that require document signing. In this tutorial, we will walk through how to add a signature pad to a Rails 8 app using Tailwind CSS, PostgreSQL, and Importmap. We'll leverage the &lt;a href="https://github.com/szimek/signature_pad" rel="noopener noreferrer"&gt;signature_pad&lt;/a&gt; JavaScript library to enable users to draw their signatures directly within a form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install Signature Pad
&lt;/h2&gt;

&lt;p&gt;Rails 8 with Importmap allows us to pin JavaScript libraries easily. Start by running the following command to install &lt;code&gt;signature_pad&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;bin/importmap pin signature_pad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will pin &lt;code&gt;signature_pad&lt;/code&gt; and update the &lt;code&gt;importmap.rb&lt;/code&gt; file with:&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="n"&gt;pin&lt;/span&gt; &lt;span class="s2"&gt;"signature_pad"&lt;/span&gt; &lt;span class="c1"&gt;# @5.0.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create a Stimulus Controller
&lt;/h2&gt;

&lt;p&gt;Next, we will create a Stimulus controller to handle the signature pad interactions. Run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bin/rails generate stimulus signature_pad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, open the generated &lt;code&gt;signature_pad_controller.js&lt;/code&gt; file and replace its contents with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@hotwired/stimulus&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;SignaturePad&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;signature_pad&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;targets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;canvas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;signaturePad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SignaturePad&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;canvasTarget&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;dotSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;minWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;maxWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please add signature before saving.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;disconnect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;signaturePad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;off&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;signaturePad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;canvasTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBlob&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signatureFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;signature.png&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;image/png&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataTransfer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DataTransfer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nx"&gt;dataTransfer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;signatureFile&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inputTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dataTransfer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submit&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation of the Stimulus Controller
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;static targets = ["canvas", "input"]&lt;/code&gt;&lt;/strong&gt;: Defines the elements our controller interacts with.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;connect()&lt;/code&gt;&lt;/strong&gt;: Initializes &lt;code&gt;signature_pad&lt;/code&gt; on the canvas element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;disconnect()&lt;/code&gt;&lt;/strong&gt;: Cleans up the signature pad instance when the controller is removed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;clear()&lt;/code&gt;&lt;/strong&gt;: Clears the signature from the canvas when the clear button is clicked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;submit(event)&lt;/code&gt;&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Prevents the default form submission.&lt;/li&gt;
&lt;li&gt;Converts the signature drawn on the canvas to a &lt;code&gt;blob&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Creates a &lt;code&gt;File&lt;/code&gt; object and adds it to a &lt;code&gt;DataTransfer&lt;/code&gt; instance.&lt;/li&gt;
&lt;li&gt;Assigns the file to the hidden input field so it gets submitted with the form.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Set Up the Model
&lt;/h2&gt;

&lt;p&gt;To start, let’s assume we have a Consent model. We will now add an attached signature:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Consent&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:employee&lt;/span&gt;

  &lt;span class="n"&gt;has_one_attached&lt;/span&gt; &lt;span class="ss"&gt;:signature&lt;/span&gt; &lt;span class="c1"&gt;#Add this line&lt;/span&gt;

  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:last_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:phone_number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:date_signed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:accepted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;inclusion: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;in: &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="ss"&gt;message: &lt;/span&gt;&lt;span class="s2"&gt;"must be accepted"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:advisor_authorization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:consent_persistence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:information_confirmation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;inclusion: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;in: &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="ss"&gt;message: &lt;/span&gt;&lt;span class="s2"&gt;"must be checked"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Update the Form
&lt;/h2&gt;

&lt;p&gt;Now, let's update the consent form to include the signature pad:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form_for&lt;/span&gt; &lt;span class="vi"&gt;@consent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;url: &lt;/span&gt;&lt;span class="n"&gt;wizard_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;method: :put&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"space-y-6 mb-12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;data: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;controller: &lt;/span&gt;&lt;span class="s2"&gt;"signature-pad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;action: &lt;/span&gt;&lt;span class="s2"&gt;"submit-&amp;gt;signature-pad#submit"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;label&lt;/span&gt; &lt;span class="ss"&gt;:signature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"block text-sm font-normal text-slate-700 mt-8 mb-2"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
      Client Signature &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-purple-500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;*&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;consent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;persisted?&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;consent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attached?&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
      &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;image_tag&lt;/span&gt; &lt;span class="n"&gt;consent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"max-w-[300px] rounded border border-gray-300 mb-2"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;file_field&lt;/span&gt; &lt;span class="ss"&gt;:signature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;data: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;signature_pad_target: &lt;/span&gt;&lt;span class="s2"&gt;"input"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;accept: &lt;/span&gt;&lt;span class="s2"&gt;"image/png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;hidden: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;canvas&lt;/span&gt; &lt;span class="ss"&gt;width: &lt;/span&gt;&lt;span class="mi"&gt;950&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;height: &lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;data: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;signature_pad_target: &lt;/span&gt;&lt;span class="s2"&gt;"canvas"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"rounded-lg border border-gray-300 mb-2 hover:bg-gray-50 cursor-pointer"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;div&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"flex justify-between"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
      &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;button&lt;/span&gt; &lt;span class="s2"&gt;"Clear"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="s2"&gt;"button"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;data: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;action: &lt;/span&gt;&lt;span class="s2"&gt;"signature-pad#clear"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"bg-gray-200 hover:bg-gray-300 text-gray-500 px-2 py-1 rounded"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-1/2 mt-2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;label&lt;/span&gt; &lt;span class="ss"&gt;:date_signed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"block text-sm font-normal text-slate-700"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
      Date signed &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-purple-500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;*&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;date_field&lt;/span&gt; &lt;span class="ss"&gt;:date_signed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"block w-full rounded-lg border-slate-200 shadow-sm focus:border-purple-500 focus:ring-purple-500 sm:text-sm"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
      &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;consent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:date_signed&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;any?&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-2 text-sm text-red-600"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;consent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:date_signed&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="s2"&gt;", "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
      &lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-between mt-16"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;link_to&lt;/span&gt; &lt;span class="s2"&gt;"Go back"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;previous_wizard_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"px-4 py-2 text-sm font-medium text-gray-700 border border-gray-300 rounded-md hover:bg-gray-100"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submit&lt;/span&gt; &lt;span class="s2"&gt;"Next step"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"px-6 py-2 text-sm font-medium text-white bg-purple-500 rounded-md hover:bg-purple-600 focus:outline-none focus:ring focus:ring-purple-300 cursor-pointer"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How the Form Uses the Stimulus Controller
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;data: { controller: "signature-pad", action: "submit-&amp;gt;signature-pad#submit" }&lt;/code&gt;&lt;/strong&gt;: Attaches the Stimulus controller to the form and links the &lt;code&gt;submit&lt;/code&gt; action to the &lt;code&gt;submit&lt;/code&gt; method in the controller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Canvas Element (&lt;code&gt;data: { signature_pad_target: "canvas" }&lt;/code&gt;)&lt;/strong&gt;: This allows the controller to find the canvas for drawing signatures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hidden File Input (&lt;code&gt;data: { signature_pad_target: "input" }&lt;/code&gt;)&lt;/strong&gt;: Stores the converted signature as an image file for form submission.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Testing the Signature Pad
&lt;/h2&gt;

&lt;p&gt;Start your Rails server:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fae2zuc4ije7g5i98zio7.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%2Fae2zuc4ije7g5i98zio7.png" alt="signature" width="800" height="202"&gt;&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%2Fez982od22s2yskxxy0f1.gif" 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%2Fez982od22s2yskxxy0f1.gif" alt="Gif signature" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate to your form page and test drawing a signature. When you submit, the signature should be stored as an attached file in your database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we integrated &lt;code&gt;signature_pad&lt;/code&gt; into a Rails 8 application using Stimulus, Tailwind CSS, and PostgreSQL. We built a consent form where users can draw their signatures, store them in Active Storage, and submit them as part of their agreement. This approach can be extended to any document signing feature in a Rails app!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sending Emails in Rails Applications with Resend and Devise.</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Mon, 13 Nov 2023 11:53:43 +0000</pubDate>
      <link>https://dev.to/ukaypromise/sending-emails-in-rails-applications-with-resend-and-devise-e7p</link>
      <guid>https://dev.to/ukaypromise/sending-emails-in-rails-applications-with-resend-and-devise-e7p</guid>
      <description>&lt;p&gt;In one of the projects I worked on for a client, I needed to configure an email service for the Rails application, and I wanted to try something different than the standard SendGrid or Gmail smtp configurations.&lt;br&gt;
My client had already provided domain-specific emails from Namecheap, and I wanted to set up the configuration using those customized domain emails.&lt;/p&gt;

&lt;p&gt;I asked a coworker, who suggested I try &lt;a href="https://resend.com"&gt;Resend&lt;/a&gt;. I wasn't sure if it offered any Rails assistance, so I read through the documentation and was surprised to find a &lt;a href="https://resend.com/docs/send-with-rails"&gt;Rails section&lt;/a&gt;. It was extremely simple to set up with minimal configuration.&lt;/p&gt;

&lt;p&gt;For the purposes of this article, I'm assuming you've already configured user authentication with devise.&lt;/p&gt;

&lt;p&gt;Resend is a powerful email service that can handle transactional emails, such as password reset emails or email confirmations, which are often required in a Devise setup. In this article, we'll walk you through how to integrate Resend with Devise in a Rails application.&lt;/p&gt;

&lt;p&gt;You can visit &lt;a href="https://resend.com"&gt;Resend&lt;/a&gt; and sign up for an account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Resend Gem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, you need to install the Resend gem. You can do this by running 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;gem install resend

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Configure Resend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next, you need to configure Resend with your API keys. This is typically done in an initializer, create a resend.rb file inside the &lt;code&gt;config/initializers&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;# config/initializers/resend.rb
Resend.api_key = "your-api-key"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To generate your api_key, you can navigate to the API key section and create an api_key, kindly copy it and save it somewhere.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jZHT946H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6u72ex0aysks83chynzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jZHT946H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6u72ex0aysks83chynzo.png" alt="Resend" width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replace "your-api-key" with the API key you received from Resend. You can find your API key in the Resend dashboard.&lt;br&gt;
This would be bad practice to push our api_key to github, so we would be using the rails credentials.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EDITOR="code --wait" rails credentials:edit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would open the credentials.yml file in your vscode, simple add your api_key like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resend:
  api_key: your_api_key_goes_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Set Up Email Delivery Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After that, you need to set up the email delivery method in your Rails application. This is done by configuring the action_mailer settings in your environment configuration files. Here's how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# config/environments/production.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: "this_is_your_domain.com", protocol:"https" }
config.action_mailer.delivery_method = :resend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Configure Devise&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In order to use Resend with Devise, you need to configure Devise's mailer to use the correct delivery method. This is done in the Devise initializer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# config/initializers/devise.rb
config.mailer_sender = 'promise@this_is_your_domain.com'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the email address with the email address you want to use for sending emails.&lt;/p&gt;

&lt;p&gt;For my case i have my domain from Namecheap, so let us do some more settings to make this work.&lt;br&gt;
On the domain section on Resend, let us add our domain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sFz26agW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqxnsd32qcoza600xfgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sFz26agW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqxnsd32qcoza600xfgt.png" alt="Add domain" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding a domain, you would need to verify it by setting up MX record and TXT record on your Namecheap Advanced DNS settings. Resend would provide this records and you only need to copy to your Namecheap Advanced DNS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sQpTnPFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie5q9o4w7vkxwauitjl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sQpTnPFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie5q9o4w7vkxwauitjl5.png" alt="DNS setup" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once it is all green, then it should work as expected. You can test and see it works great.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aE5Bsmec--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsp0t9vja3t2zi4hmtrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aE5Bsmec--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsp0t9vja3t2zi4hmtrm.png" alt="Email test" width="800" height="389"&gt;&lt;/a&gt;&lt;br&gt;
Finally, you can test if the email sending works by triggering an email send. For example, you can try resetting a user's password, which should send a password reset email to the user's email address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this article, we went through how to set up Resend with Devise in a Rails application. While this guide should cover most use cases, always refer to the official documentation of Resend and Devise for the most accurate information. If you encounter any issues during the setup process, don't hesitate to leave a comment or ask a question. We're here to help!&lt;br&gt;
If this was helpfull, kindly leave a comment.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Consuming Other APIs in a Rails App.</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Sat, 22 Apr 2023 16:51:48 +0000</pubDate>
      <link>https://dev.to/ukaypromise/consuming-other-apis-in-a-rails-app-2bi4</link>
      <guid>https://dev.to/ukaypromise/consuming-other-apis-in-a-rails-app-2bi4</guid>
      <description>&lt;p&gt;Ruby on Rails is a popular web framework for building web applications and APIs. It is widely used by developers due to its ease of use, convention over configuration approach, and robust features. Rails is known for its quick development time, which makes it a go-to framework for startups and developers who want to build prototypes quickly.&lt;/p&gt;

&lt;p&gt;Rails is also used extensively for building APIs. APIs are essential for applications that require integration with other services or applications. A well-designed API makes it easy to interact with the application or service programmatically. Rails has built-in support for building APIs, which makes it a popular choice for developers.&lt;/p&gt;

&lt;p&gt;However, consuming other APIs in a Rails application can be challenging compared to JavaScript, React, or Node applications. The challenges are primarily due to the differences in the way these frameworks handle asynchronous requests and data processing.&lt;/p&gt;

&lt;p&gt;JavaScript and React are known for their ability to handle asynchronous requests and data processing seamlessly. This is because JavaScript and React use client-side code to handle these requests, making it easy to build fast and responsive web applications. Node, on the other hand, is known for its ability to handle large-scale applications that require a lot of data processing.&lt;/p&gt;

&lt;p&gt;Rails, on the other hand, is a server-side framework that relies on traditional server-side processing. This means that Rails applications need to send requests to other APIs and wait for the response before processing the data. This can slow down the application and make it less responsive.&lt;/p&gt;

&lt;p&gt;Another challenge of consuming other APIs in Rails applications is the need to parse and transform data into the required format. Unlike JavaScript and React, which can handle JSON data easily, Rails requires more effort to parse and transform data. This is because Rails relies on Ruby's built-in parsing libraries, which may not be as efficient as JavaScript's parsing libraries.&lt;/p&gt;

&lt;p&gt;To overcome these challenges, Rails developers can use libraries and gems that simplify the process of consuming APIs. Some popular gems for consuming APIs in Rails include HTTParty, Faraday, and RestClient. These gems provide a simple and easy-to-use interface for sending requests and processing responses.&lt;/p&gt;

&lt;p&gt;In conclusion, while Rails is an excellent framework for building web applications and APIs, consuming other APIs in Rails applications can be challenging compared to JavaScript, React, or Node applications. However, by using the right libraries and gems, Rails developers can overcome these challenges and build fast and responsive applications that integrate seamlessly with other services and applications.&lt;/p&gt;

&lt;p&gt;If you have never implemented an external API in your rails Application, then you are in the right place as i will be showing you just how to work with other APIs in your Rails APP.&lt;br&gt;
For this tutorials, We will be working with the popular News API that i can across while learning NextJs by building a Daily News web App.&lt;/p&gt;

&lt;p&gt;You can signup at &lt;a href="https://newsapi.org/docs/endpoints/everything"&gt;News API&lt;/a&gt; and get a free API key that we will be using for this tutorial.&lt;/p&gt;

&lt;p&gt;Create a new Rails app using 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;rails new news-api-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go into the newly created app directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd news-api-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the Gemfile and add the 'news-api' gem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'news-api'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run bundle install to install the new gem:&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;Create a new file named 'news_api.rb' in the 'config/initializers' directory. This file will be used to initialize the News API object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# config/initializers/news_api.rb

NewsApi = News.new("YOUR_API_KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace "YOUR_API_KEY" with your actual News API key.&lt;/p&gt;

&lt;p&gt;Create a new model named 'news_article' using 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;rails g model news_article title:string description:text url:string source:string published_at:datetime

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run rails db:migrate to create the news_articles table in the database.&lt;/p&gt;

&lt;p&gt;Edit the 'news_article.rb' file and add the following line at the top to include the NewsApi module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require_relative '../../config/initializers/news_api'

class NewsArticle &amp;lt; ApplicationRecord
    def self.get_news_articles
        # Use the NewsApi class here
        NewsApi.get_news
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new controller named 'news_controller' using 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;rails g controller news index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a controller file and a view file for the index action.&lt;/p&gt;

&lt;p&gt;Edit the 'news_controller.rb' file and add the following code to the index action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class NewsController &amp;lt; ApplicationController
  def index
    articles = NewsApi.get_top_headlines(country: 'us')
    @news_articles = articles.map do |article|
      NewsArticle.create(title: article.title, description: article.description, url: article.url, published_at: article.publishedAt)
    end
  end
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code fetches the top headlines for the country 'us' using the News API, creates a new news article object for each article, and stores it in the @news_articles instance variable.&lt;/p&gt;

&lt;p&gt;Edit the 'index.html.erb' file and add the following code to display the list of news articles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;% @news_articles.each do |article| %&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;h2&amp;gt;&amp;lt;%= article.title %&amp;gt;&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;%= article.description %&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;Source: &amp;lt;%= article.source %&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;Published at: &amp;lt;%= article.published_at %&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code loops through the @news_articles instance variable and displays the title, description, source, and published date of each news article.&lt;/p&gt;

&lt;p&gt;Run rails server to start the app, and navigate to &lt;a href="http://localhost:3000/news"&gt;http://localhost:3000/news&lt;/a&gt; to see the list of news articles fetched from the News API.&lt;/p&gt;

&lt;p&gt;That's it! You now have a simple Rails app that fetches a list of news from the News API and displays them on a web page.&lt;/p&gt;

&lt;p&gt;You can also test it out in your rails console to see just how the data looks. In your terminal, run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then run this line of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;articles = NewsApi.get_top_headlines(country: 'us')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;irb(main):017:0&amp;gt; articles = NewsApi.get_top_headlines(country: 'us')
=&amp;gt; 
[#&amp;lt;Everything:0x000000010b37b3b8
...
irb(main):018:0&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you run "articles" in your rails console, you should get an array of news articles.&lt;/p&gt;

&lt;p&gt;I hope this was helpful.&lt;br&gt;
Happy Coding!!!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Build Your First Rails API</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Thu, 05 Jan 2023 00:52:43 +0000</pubDate>
      <link>https://dev.to/ukaypromise/build-your-first-rails-api-3k5a</link>
      <guid>https://dev.to/ukaypromise/build-your-first-rails-api-3k5a</guid>
      <description>&lt;p&gt;In this article i am going to quickly show you how you can build a simple rails api. This will give you an idea of what building API entails.&lt;br&gt;
I am going to make this as simple as possible so that you understand the basics.&lt;br&gt;
The api end point that we will be building will get us a random greetings.&lt;br&gt;
Lets dive in and get our hands dirty.&lt;br&gt;
First, you will need to create a Rails API app by running 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;rails new my_api --api --database=postgresql

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will need to create the database by running&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:create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you will need to create a model for your greetings table by running 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;rails g model Greeting content:string

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following command to create the table in your database:&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:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you will need to seed your database with some greeting data. You can do this by adding the following lines of code to the db/seeds.rb file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Greeting.create(content: "Hello")
Greeting.create(content: "Hi")
Greeting.create(content: "Good morning")
Greeting.create(content: "Good afternoon")
Greeting.create(content: "Good evening")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following command to seed your database:&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:seed

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can create your API endpoint. In your config/routes.rb file, add the following line of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/random_greeting', to: 'greetings#random'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a GreetingsController by running 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;rails g controller Greetings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your app/controllers/greetings_controller.rb file, add the following action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def random
  greeting = Greeting.order("RANDOM()").first
  render json: { greeting: greeting.content }
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when you make a GET request to the '/random_greeting' endpoint, it will return a JSON response with a random greeting from your table.&lt;br&gt;
I hope this helps! Let me know if you have any questions.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>How to save to Local storage</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Sat, 31 Dec 2022 10:59:06 +0000</pubDate>
      <link>https://dev.to/ukaypromise/how-to-save-to-local-storage-4438</link>
      <guid>https://dev.to/ukaypromise/how-to-save-to-local-storage-4438</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Saving data to local storage is a useful way to persist data in a web application. Local storage allows you to store data in the user's browser, which means that the data is available even if the user closes the browser or navigates to a different website. This can be useful for storing user preferences, temporary data, or any other information that you want to make available across sessions.&lt;/p&gt;

&lt;p&gt;In this article, we will look at how to save data to local storage using JavaScript. We will start by looking at the basics of local storage, including how to set and get values. We will then explore some more advanced techniques, such as storing complex objects and handling errors.&lt;/p&gt;

&lt;p&gt;Basics of Local Storage&lt;/p&gt;

&lt;p&gt;To use local storage in JavaScript, you first need to check if the browser supports it. You can do this using the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (typeof(Storage) !== "undefined") {
  // local storage is supported
} else {
  // local storage is not supported
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If local storage is supported, you can use the following methods to set and get values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// set a value
localStorage.setItem("key", "value");

// get a value
var value = localStorage.getItem("key");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also remove a value from local storage using the removeItem method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localStorage.removeItem("key");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also clear all values from local storage using the clear method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localStorage.clear();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Storing Complex Objects
&lt;/h2&gt;

&lt;p&gt;Local storage only allows you to store strings, so if you want to store complex objects (such as arrays or objects), you will need to serialize them first. You can use the JSON.stringify method to serialize an object, and the JSON.parse method to deserialize a string back into an object.&lt;/p&gt;

&lt;p&gt;For example, to store an array in local storage, you could do 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;var array = [1, 2, 3];

// serialize the array
var serializedArray = JSON.stringify(array);

// store the serialized array in local storage
localStorage.setItem("array", serializedArray);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To retrieve the array from local storage, you would do 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;// get the serialized array from local storage
var serializedArray = localStorage.getItem("array");

// deserialize the array
var array = JSON.parse(serializedArray);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Handling Errors&lt;/p&gt;

&lt;p&gt;There are a few potential errors that you may encounter when working with local storage. One common error is trying to store too much data. Local storage has a limited size (usually around 5MB), and if you try to store more data than the available space, you will get a QuotaExceededError.&lt;/p&gt;

&lt;p&gt;To handle this error, you can catch it using a try/catch block and display an error message to the user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
  localStorage.setItem("key", "value");
} catch (e) {
  if (e.name === "QuotaExceededError") {
    alert("Error: Local storage is full.");
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another potential error is trying to access local storage when it is disabled. This can happen if the user has disabled&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A Quick Overview of TypeScript</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Fri, 30 Dec 2022 10:44:06 +0000</pubDate>
      <link>https://dev.to/ukaypromise/a-quick-overview-of-typescript-21c5</link>
      <guid>https://dev.to/ukaypromise/a-quick-overview-of-typescript-21c5</guid>
      <description>&lt;p&gt;TypeScript is a programming language that is a super set of JavaScript, meaning that any valid JavaScript code is also valid TypeScript code. TypeScript was developed and is maintained by Microsoft and was first released in 2012. It has gained widespread adoption in the developer community due to its ability to add type checking and other features to JavaScript.&lt;/p&gt;

&lt;p&gt;One of the main benefits of using TypeScript is that it can catch errors before you even run your code. This is because TypeScript has a type system that allows you to specify the data types of variables and function parameters, and the compiler will check your code to ensure that you are using the correct types. For example, consider the following JavaScript code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(name) {
  return "Hello, " + name;
}

console.log(greet(10));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, we are passing a number to the greet function, which expects a string. When this code is run, it will output "Hello, 10", but this is likely not what we intended. With TypeScript, we can specify the type of the name parameter as a string, and the compiler will throw an error if we try to pass anything other than a string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function greet(name: string) {
  return "Hello, " + name;
}

console.log(greet(10));  // This will cause a TypeScript error

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another benefit of using TypeScript is that it can provide improved code completion and suggestion features in your editor or IDE. This is because the TypeScript compiler has information about the types of variables and functions, and can use this to provide better suggestion when you are writing code.&lt;/p&gt;

&lt;p&gt;In addition to adding type checking to your code, TypeScript also includes features such as classes, interfaces, and modules, which are not available in standard JavaScript.&lt;/p&gt;

&lt;p&gt;For example, here is how you can define a class in TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal {
  name: string;
  constructor(name: string) {
    this.name = name;
  }
  makeNoise() {
    console.log("Some generic animal noise");
  }
}

const animal = new Animal("Fluffy");
console.log(animal.name);  // Outputs: "Fluffy"
animal.makeNoise();  // Outputs: "Some generic animal noise"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also define interfaces in TypeScript, which are contracts that specify the shape of an object. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Point {
  x: number;
  y: number;
}

const point: Point = { x: 0, y: 0 };

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modules in TypeScript allow you to organize your code into logical units and can help to prevent naming conflicts. You can define a module like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module Shapes {
  export class Triangle {
    // ...
  }
  export class Square {
    // ...
  }
}

const triangle = new Shapes.Triangle();
const square = new Shapes.Square();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to these features, TypeScript also includes support for decorators, which are functions that can be used to modify the behavior of a class or its members. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function log(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
  console.log(

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Why You haven't landed the Tech Job yet!</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Mon, 24 Oct 2022 12:04:17 +0000</pubDate>
      <link>https://dev.to/ukaypromise/why-you-havent-landed-the-tech-job-yet-2cjl</link>
      <guid>https://dev.to/ukaypromise/why-you-havent-landed-the-tech-job-yet-2cjl</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MklIeTRY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbpvr5v1qjw2twrfjwws.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MklIeTRY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbpvr5v1qjw2twrfjwws.jpeg" alt="can land a tech job" width="640" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post is for you if you are just starting out in tech or if you have already begun but haven't landed your first job yet. I was ecstatic when I wrote my first lines of code. I had the idea that I could completely remake the cosmos with just a few lines of code. I've always wanted to have an impact on my community, so discovering how to instruct the computer on what to do, when to do it, and exactly how to do it made me extremely happy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seek Mentors
&lt;/h2&gt;

&lt;p&gt;I had the foresight to ask knowledgeable computer experts for advice on which aspects of tech would best suit and appeal to my spirit. After much consideration and researching, I ultimately decided to pursue a career in full stack development, which I did after completing a three-month comprehensive course in UI/UX design. I got off to a good start by looking for and finding a mentor. He explained what it took to become a Fullstack Developer; nevertheless, he did not provide me with enough information to secure my first position.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn and Keep Learning.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C4PQMV8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh7lwph5pis8zowqrcy5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C4PQMV8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh7lwph5pis8zowqrcy5.jpeg" alt="starting as a junior developer" width="740" height="415"&gt;&lt;/a&gt;&lt;br&gt;
After dedicating myself to intense personal study and development for almost five months (with only four hours of sleep each day), I felt confident using HTML, CSS, and JavaScript and that I could defy the laws of physics. I had completed 100 hours of Udemy coursework and over 1,000 hours of YouTube videos, and I felt like the King of the North getting ready to sit on the Iron throne made of a thousand blades of algorithms and Data Structures, which I had never been told about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stay Positive While learning.
&lt;/h2&gt;

&lt;p&gt;I started applying for tech jobs in front-end development right away, but I was told I wasn't qualified because the position required someone with React experience. I subsequently enrolled in a ReactJS course to further improve my chances of landing the dream position, only to hear that I still needed to learn how to use GitHub and git.&lt;br&gt;
As time went on, I continued to receive rejection emails based on the fact that I lacked other essential abilities. Because I was so concerned, I had to talk to my mentor about it. Before I reveal the answer to your question regarding what happened to the throne of a thousand blades of algorithms and data structures, there is something you should know.&lt;/p&gt;

&lt;p&gt;Let's get back on track. Disgusted, defeated, and on the verge of giving up, I made the decision to go meet my mentor to find out why finding a job seemed to be tougher for me than it had been for him. Was he lying to me? Will $5,000 per month ever be mine?&lt;/p&gt;

&lt;h2&gt;
  
  
  Easy way Out! Join Microverse.
&lt;/h2&gt;

&lt;p&gt;The discussion with my mentor was very different this time. He informed me that although I had a basic understanding of the necessary tools, I still needed to learn about industry standards, which I might only do so through working in the tech industry because numerous YouTube videos could never teach you that. He basically introduced me to Microverse on that crucial day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vN7O1yqv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1203bek9cm4zgvknstu3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vN7O1yqv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1203bek9cm4zgvknstu3.jpeg" alt="Microverse" width="673" height="455"&gt;&lt;/a&gt;&lt;br&gt;
Microverse provides a full-time remote web development bootcamp to help graduates prepare for careers in technology. This program emphasizes pair programming and real-time collaboration with students, simulating workplace team dynamics.&lt;br&gt;
Microverse provides each student with an accountability partner and a global support network. Students learn technical skills like JavaScript and HTML and soft skills like cross-cultural communication and remote work best practices.&lt;br&gt;
Microverse full-time web development bootcamp helps students learn practical skills in coding and full-stack development. The program also provides career support services that cover job search skills, interviewing, and resume building.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn Algorithm and Data Structures
&lt;/h2&gt;

&lt;p&gt;That day, I returned home and applied for the Microverse program. Since then, Microverse has been the best decision I've ever made in terms of getting into tech.&lt;br&gt;
Learning and solving Algorithms and Data Structures was one of the weekly core activities at Microverse. When I first heard about Algorithms and Data Structures , I was skeptical about why I should try to understand it. Building websites or web applications should not rely solely on my understanding of algorithms and data structures (a misconception I am yet to forgive myself for ). I simply took it for granted and I paid dearly for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build a Great Resume and a good Social Media Presence.
&lt;/h2&gt;

&lt;p&gt;I had already written a good resume by the time I finished the third module of the Microverse curriculum, so I decided to try my luck by applying for jobs on LinkedIn. At this point, I knew I'd improved far beyond my wildest expectations.&lt;br&gt;
I received an email a few days ago with a link to a test for the role I had previously applied for. The test would last for 24 hours. I saw this as an opportunity to land my first job, so I jumped in to take the test without adequate preparation, only to run into algorithms and data structures. The test came with instructions that prevented me from switching browser tabs. I knew exactly what that meant because I once wrote an application that tracks when a user leaves and returns to a browser tab. There was no assistance from KingsLanding (Google) or Dragon Stone (Stack overflow). I did the best I could with what I was knew. I was only able to eventually finish four of the six activities. Algorithms and data structures humble me. At that point, I had figured out what I had been missing all this time. I want to take my algorithm and data structure courses seriously at Microverse.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vN9IDjhZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ku4vxaqzqqe01akjpqe.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vN9IDjhZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ku4vxaqzqqe01akjpqe.jpg" alt="Land your first Job as a developer" width="880" height="738"&gt;&lt;/a&gt;&lt;br&gt;
This was the missing link that has kept many junior and mid-level developers from getting a job. Nobody is going to tell you about it. This is why you will never be able to sit on the Iron Throne.&lt;br&gt;
There are hundreds of resources available to help you learn algorithms and data structures. To begin, you must master the art of problem solving. I urge you to continue working on your data structures and algorithms. Join platforms such as &lt;a href="https://www.coderbyte.com/solution/Alphabet%20Searching"&gt;coderbyte&lt;/a&gt;, &lt;a href="https://leetcode.com/explore/challenge/"&gt;leetcode&lt;/a&gt;, and &lt;a href="https://www.hackerrank.com/"&gt;hackerrank&lt;/a&gt;. Solve as many as you can as they are building blocks for becoming a better developer.&lt;/p&gt;

&lt;p&gt;If you really want to pass coding interviews and land your first job, then you should spend a good amount of time working on data structures and algorithms. It won't only help you ace interviews but it will also make you a better software developer.&lt;br&gt;
I have taken my time to prepare this list of resources to help you get started with data structures and algorithms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The common sense guide to Data Structure and Algorithm also known as the pragmatic programmer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://drive.google.com/file/d/14uxOqIJsEVJrBiCLt4S4pG-_0CV8k4Yb/view?usp=sharing"&gt;Master the coding Interview&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/course/master-the-coding-interview-data-structures-algorithms/?utm_source=adwords&amp;amp;utm_medium=udemyads&amp;amp;utm_campaign=DataStructures_v.PROF_la.EN_cc.ROW&amp;amp;utm_content=deal4584&amp;amp;utm_term=_._ag_121857712017_._ad_535699942243_._kw_learning+data+structures+and+algorithms_._de_m_._dm__._pl__._ti_kwd-818805434095_._li_1010297_._pd__._&amp;amp;matchtype=p&amp;amp;gclid=CjwKCAjw79iaBhAJEiwAPYwoCCRnJsLegcMSgO08JNczPSRi-3vCsO_T_qxMAQB3w0FDk8cp6ySUIRoCN3gQAvD_BwE"&gt;Top 45 Data Structure&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.simplilearn.com/data-structure-interview-questions-and-answers-article"&gt;Interview Questions and Answers for 2023&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/h5bp/Front-end-Developer-Interview-Questions"&gt;Frontend developer Interview Questions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://frontendmasters.com/courses/algorithms/"&gt;Frontend Masters&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you at the top.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript concepts to know before building your First React App</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Fri, 30 Sep 2022 22:40:15 +0000</pubDate>
      <link>https://dev.to/ukaypromise/javascript-concepts-to-know-before-building-your-first-react-app-24ie</link>
      <guid>https://dev.to/ukaypromise/javascript-concepts-to-know-before-building-your-first-react-app-24ie</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qSM76AWg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/095lw5islh2cowcya14w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qSM76AWg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/095lw5islh2cowcya14w.jpg" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are some important concepts you need to understand before starting out to learning react. They are arrow functions, template literals, object destructuring, fetch, async functions, promise, callbacks, array functions and many more.&lt;/p&gt;

&lt;p&gt;The intention of this article is to highlight the JavaScript fundamentals that aspiring React developers should master before actually getting into React. Modern JavaScript features, which were mostly introduced with ES2015, are built upon in React.&lt;br&gt;
React is a library for creating UI components that may be the foundation of both web and mobile applications, as you probably already know. React stands out from some of its rivals since all of its code is written in JavaScript. Even the HTML-like templates are created in JS using JSX, a JS language extension for UI component organization. &lt;/p&gt;

&lt;p&gt;Let's move on from the definitions and discuss the JavaScript fundamentals you must master before studying React.&lt;br&gt;
Variables&lt;br&gt;
You must understand how to declare a variable in JavaScript before beginning to use React. There are three ways to declare variables in JavaScript. using const, let, or var. They each have benefits and drawbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt;&lt;br&gt;
The primary tenet of React is to split large projects into smaller parts or components. And either functions or classes make up those components. Therefore, it is crucial to understand how to declare a function in JavaScript. Similar to variables, a function can be declared in more than two different methods. However, these two are regular function syntax and arrow functions.&lt;br&gt;
Modern codebases almost always use the arrow function, a new ES6 feature that makes the code more clear and succinct. We can use this capability to write functions with a more concise syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Template Literals.&lt;/strong&gt;&lt;br&gt;
When creating a web application, working with strings is typical. In prior JavaScript (ES5) versions, you had to use the + operator to concatenate (append) a string to a variable. Additionally, it has a poor aesthetic and is challenging to understand. However, using an ES6 template literal, you may now concatenate strings with variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Destructuring Assignment&lt;/strong&gt;&lt;br&gt;
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let a, b, rest;&lt;br&gt;
[a, b] = [10, 20];&lt;br&gt;
console.log(a);&lt;br&gt;
// expected output: 10&lt;br&gt;
console.log(b);&lt;br&gt;
// expected output: 20&lt;br&gt;
[a, b, ...rest] = [10, 20, 30, 40, 50];&lt;br&gt;
console.log(rest);&lt;br&gt;
// expected output: Array [30,40,50]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array Methods&lt;/strong&gt;&lt;br&gt;
Array methods in JavaScript are methods for working with arrays. Future usage of these tactics will benefit from understanding how they work. Since you'll find yourself utilizing them regularly once you begin using React to build projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fetch&lt;/strong&gt;&lt;br&gt;
The fetch() method in JavaScript is used to request to the server and load the information on the webpages. The request can be of any APIs that return the data of the format JSON or XML. This method returns a promise.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fetch('url')           //api for the get request&lt;br&gt;
  .then(response =&amp;gt; response.json())&lt;br&gt;
  .then(data =&amp;gt; console.log(data));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I advise gaining a solid understanding of JavaScript principles before learning React because writing vanilla JavaScript code makes up the majority of React development. You will get off to a much better start with this study approach, I guarantee you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Meet The Tech Bro</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Sat, 30 Jul 2022 19:42:49 +0000</pubDate>
      <link>https://dev.to/ukaypromise/meet-the-tech-bro-21cb</link>
      <guid>https://dev.to/ukaypromise/meet-the-tech-bro-21cb</guid>
      <description>&lt;p&gt;When I finished the last Algorithm task for the week, I felt this joy all around me. It was the only task left for me to complete this week in Microverse's first module. DSA (Data Structure and Algorithm) has become a challenge that I must master (Yes, I have, to pass coding interviews). I was relieved when I finally got around to answering the question and having my code pass the auto-grading workflow.&lt;/p&gt;

&lt;p&gt;Let me briefly recount my experience at Microverse.&lt;br&gt;
Before Microverse, I had taken HTML CSS and JavaScript courses on Udemy and YouTube. I ended up drowning in tutorial Hell. I was unsure of my ability to create something with what I had learned. I found myself leaping from one YouTube video to another.&lt;/p&gt;

&lt;p&gt;AltSchool's participation was appreciated because it helped me develop my thinking and confidence. A turning moment for me was having to review HTML, CSS, and JavaScript once more. The JavaScript tutor( A.K.A Rising) at AltSchool was excellent, and I eventually grasped the fundamentals that I had found difficult to grasp.&lt;/p&gt;

&lt;p&gt;At Microverse, the first day was enjoyable. I had a champion's zeal and was prepared to rule the tech world. The true trouble began at this point. I wasn't prepared for Microverse. No, way! I was telling myself that "the is too hard."&lt;/p&gt;

&lt;p&gt;The first task at Microverse was unlike anything I'd ever seen. For our project, we needed to set up linters. The Linter test and checks must be passed by the project. In addition, for each project, I had to create a pull request and submit the link for review. If the code does not meet the requirements, a code reviewer will go over it and request changes.&lt;/p&gt;

&lt;p&gt;My project kept failing the linter test, and the reviewer kept requesting that I make changes and correct the errors. I became extremely frustrated and wanted to give up. I had used up all of the reviews for that project, and I had already used two of the extra reviews I had. I was only left with one more review request. This was a watershed moment for me. I started looking for help through the various channels that were available to me. I tried numerous solutions until I was able to resolve the issues.&lt;/p&gt;

&lt;p&gt;Week two brought its own set of difficulties and challenges, but I persevered. The same goes for weeks three, four, and five. I've learned a lot and improved my problem-solving abilities. My HTML and CSS have improved. I am now completely confident in my abilities. A few things I learned at Microverse have helped redefine my character and technical skills.&lt;/p&gt;

&lt;p&gt;The first is learning how to work remotely. Every week, the morning session activity is followed by a stand-up meeting and peer programming activities with a different coding partner. I've had the opportunity to meet people from all over the world.&lt;/p&gt;

&lt;p&gt;The use of best practices for HTML, CSS, and JavaScript is the second. Additionally, I've learned how to deploy web pages using Github Pages, greatly enhanced my ability to create user interfaces (UIs) that can adapt to various screen sizes using Media queries, and used JavaScript to manipulate the DOM.&lt;/p&gt;

&lt;p&gt;My experience has truly been amazing, wow. I've been gaining knowledge at AltSchool and boosting my self-confidence at Microverse.&lt;/p&gt;

&lt;p&gt;I'm eager to learn what the upcoming Microverse module will bring. Additionally, I am ready to begin the new phase with AltSchool. I'm going to pick up a new programming language.&lt;br&gt;
Yes, I forgot to mention that at AltSchool, I switched to the backend. For the backend, I'll be leaning toward Python.&lt;/p&gt;

&lt;p&gt;Don't worry about me. I pick things up very quickly. Do not bother asking me how I intend to accomplish this. With God on my side, I know I will, and I am prepared to do anything to succeed.&lt;/p&gt;

&lt;p&gt;If you're a total beginner and you're reading this and want to get into tech, I'd suggest checking out AltSchool &lt;a href="https://www.altschoolafrica.com/"&gt;&lt;/a&gt;. If you have some prior experience, you could try Microverse &lt;a href="https://www.microverse.org/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I welcome new connections and opportunities to succeed. I will be posting tech articles frequently, so you can follow me on LinkedIn &lt;a href="https://www.linkedin.com/in/promiseuka"&gt;&lt;/a&gt; and Twitter &lt;a href="https://twitter.com/PromiseUkay?t=s6mrf9biOEKFGomtXW5CnA&amp;amp;s=09"&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cheers to a new adventure!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to fix `create-react-app` 4.0.3, which is behind the latest release (5.0.0)</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Mon, 21 Mar 2022 10:17:03 +0000</pubDate>
      <link>https://dev.to/ukaypromise/how-to-fix-create-react-app-403-which-is-behind-the-latest-release-500-4lea</link>
      <guid>https://dev.to/ukaypromise/how-to-fix-create-react-app-403-which-is-behind-the-latest-release-500-4lea</guid>
      <description>&lt;p&gt;Good day, guys!. I'm attempting to make a new rectjs project using &lt;strong&gt;&lt;em&gt;npx create-react-app my-app&lt;/em&gt;&lt;/strong&gt; today. However, I am experiencing the following issue: You're using create-react-app 4.0.3, which is older than React-most recent release (5.0.0).&lt;br&gt;
If you started learning React last year, you may have encountered this issue when using &lt;strong&gt;&lt;em&gt;'npx create-react-app'&lt;/em&gt;&lt;/strong&gt; to build a react app as a result of the recent change from 4.0.3 to 5.0.0. You'll most likely see a message on your terminal stating that you're running &lt;em&gt;'create-react-app' 4.0.3&lt;/em&gt;, which is older than the most recent release (5.0.0). As a newbie, this would put you on edge and cause you to be concerned about how to remedy it.&lt;br&gt;
Even after attempting to uninstall the previous version several times, it continues to throw back the same error. Here is an easy fix for you to consider. I'll go over the options with you here.&lt;br&gt;
Let's get started on fixing this error without spending any time.&lt;br&gt;
So, here's the problem you're seeing on your computer: You're using version 4.0.3 of 'create-react-app,' which is out of date (5.0.0)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IRTpPg7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtw97s5nvn8c2eme3rhk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IRTpPg7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtw97s5nvn8c2eme3rhk.jpg" alt="Image description" width="880" height="880"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Solution 1&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
First of all clear cache by running this command: &lt;em&gt;&lt;strong&gt;npx clear-npx-cache&lt;/strong&gt;&lt;/em&gt; or try the command &lt;em&gt;&lt;strong&gt;npm cache clean --force&lt;/strong&gt;&lt;/em&gt; using administrator mode in your terminal. Finally delete everything left (that is if there is any) from this path: C:\Users\Your_user_name\AppData\Roaming\npm-cache.&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Solution 2&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Create your app with the latest version of 5.0.0 with this command: &lt;strong&gt;&lt;em&gt;npx &lt;a href="mailto:create-react-app@5.0.0"&gt;create-react-app@5.0.0&lt;/a&gt; my-app&lt;/em&gt;&lt;/strong&gt;. Now, Your error must be solved.&lt;br&gt;
Hope this solution was helpful a lot. Comment below Your thoughts and your queries. Also, Comment below if this solution worked for you.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Blockchain Technology: Web 3.0 Developer Roadmap</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Wed, 10 Nov 2021 14:11:45 +0000</pubDate>
      <link>https://dev.to/ukaypromise/blockchain-technology-web-30-developer-roadmap-3hon</link>
      <guid>https://dev.to/ukaypromise/blockchain-technology-web-30-developer-roadmap-3hon</guid>
      <description>&lt;p&gt;&lt;em&gt;What is Blockchain technology&lt;/em&gt;? Have you ever used Google docs or Google sheets? Well if you have then you might as well be able to understand what Blockchain technology is all about. Try not to get this all confused as I will elaborate more on the comparison.&lt;/p&gt;

&lt;p&gt;Google Sheet is an excellent contrast for a better grasp of what blockchain technology is. When we generate a document and share it with a group of individuals, it is disseminated rather than replicated or moved. This results in a decentralized distribution network in which everyone has simultaneous access to the document. While another party adds changes to the document, no one is locked out, and all changes are monitored in real-time, making them entirely transparent. &lt;/p&gt;

&lt;p&gt;Blockchain is more involved than a Google Sheet, and it highlights three key concepts. The first important concept is that Blockchain is a database for storing encrypted data blocks and connects them to create a chronological single-source-of-truth for the data. Secondly, digital assets are disseminated instead of duplicated or moved, producing an immutable record of the various resources and lastly the asset is decentralized, allowing for real-time public accessibility and transparency. A visual record of alterations protects the document's integrity, fostering trust in the asset. Blockchain's inherent security characteristics, as well as the fact that it is a public ledger, make it a perfect option for almost any business.&lt;/p&gt;

&lt;p&gt;Blockchain technology is a promising and revolutionary technology because it minimizes risk, eliminates fraud, and enables transparency for many applications. An organized method will greatly accelerate your learning if you want to become a Web 3.0 Blockchain developer. Allow me to provide you with a road map that will undoubtedly guide you to your destination!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Web 3.0 Blockchain developer Requirements&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Learn a Programming Language&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;To begin your journey as a blockchain developer, you should be familiar with JavaScript as well as web development in general. If you don't have this prerequisite don’t panick. This is a good time to take a step back and learn about web programming. There are a plethora of excellent courses and tutorials available. You won't have any trouble locating suitable course. JavaScript is a very powerful language that allows you to make your website more interactive by adding functionality to you web applications. JavaScript is a versatile, beginner-friendly, and compact scripting language with a lot of flexibility. A very good place to start is at freecodecamp. and W3schools.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Learn the fundamentals of blockchain technology.&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Blockchains are a fantastic piece of technology, but they aren't easy to understand. To comprehend what you'll subsequently build on, you'll need to devote some time to it. &lt;a href="https://youtu.be/QCvL-DWcojc"&gt;Starting&lt;/a&gt; here is an excellent idea. To further understand check &lt;a href="https://youtu.be/Nc444sDAKmM"&gt;here&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;After learning this, you should have a basic understanding of blockchain technology. This is a fantastic starting point for your future studies. &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Learn Smart Contracts and Learn Solidity&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;The blockchain is programmed using smart contracts. They are pieces of code that have been distributed on the blockchain and are written in a language that blockchain nodes can execute.&lt;br&gt;
Smart contracts can accomplish practically everything from fungible and non-fungible coins to the backend of your next decentralized app. They're not like the code you're used to writing, though. They'll account for a significant percentage of your future job, so get to know them. &lt;a href="https://youtu.be/M576WGiDBdQ"&gt;Here's&lt;/a&gt; a decent primer on &lt;a href="https://youtu.be/ipwxYa-F1uY"&gt;Solidity.&lt;/a&gt;   &lt;/p&gt;

&lt;p&gt;There are a lot of blockchains out there, and practically every one of them has its manner of creating smart contracts. On the other hand, Solidity is the programming language of the Ethereum virtual machine, which is used in several other blockchains.&lt;br&gt;
Solidity isn't only useful for Ethereum. It will also assist you in the development of smart contracts on other blockchains. Solidity developers have by far the most job opportunities. Many companies are building or planning to develop on Ethereum.&lt;br&gt;
You need to know how gas works and how each line of code you write in Solidity influences the price of your smart contract's execution. There's no getting around it. Unfortunately, some businesses optimize their gas use aggressively.&lt;br&gt;
You'll need to understand how to optimize your code if you want to work in this profession because proper optimization may save millions of dollars each year for a frequently utilized app or contract. It will be a component of your work and a big part of individual interviews.&lt;br&gt;
Curious? Crypto Zombies is a fantastic way to get started with Solidity. You learn by playing a &lt;a href="https://t.co/6JSfyCblGl?amp=1"&gt;game.&lt;/a&gt; Is there anything greater than this? &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Learn how to use the blockchain as an interface&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Your frontend and smart contracts implemented on the blockchain are the two components of decentralized apps. You'll have to interface with the blockchain for your frontend to communicate with it. Libraries come in handy in this situation.&lt;br&gt;
There are two important basic ways to interface with Ethereum API-based blockchains, and these:&lt;br&gt;
• Web3.js&lt;br&gt;
• ethers.js&lt;br&gt;
Choose one and master it thoroughly. It'll come in handy. From now on, it will be one of your most useful tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;It may appear not easy to learn Web3.0 and blockchain programming, but everyone can accomplish it. While rapid adoption of Web 3.0 is still a long way off, we can see the beginnings of its potential. The internet uses blockchain to advance towards the subsequent development of the web, from bitcoin to smart gadgets. While some of these developments may appear perplexing to people outside the technology industry, there is no need to be concerned about all of them happening at once. Changes to the internet take time and money to produce, so they are frequently slow and incremental, giving the ordinary user time to learn and adapt.&lt;br&gt;
Start with the basics of computer science, JavaScript, Solidity, and cutting-edge DeFi applications.&lt;br&gt;
Blockchain Development is not something you can learn in a week, but you can learn in a year if you put in the effort.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Props and State in React Components</title>
      <dc:creator>Engr. Promise</dc:creator>
      <pubDate>Sat, 06 Nov 2021 14:57:03 +0000</pubDate>
      <link>https://dev.to/ukaypromise/props-and-state-in-react-components-35mf</link>
      <guid>https://dev.to/ukaypromise/props-and-state-in-react-components-35mf</guid>
      <description>&lt;p&gt;It is essential you have a good understanding of props and States in both functional and class components. props influences what is rendered in the screen. props are optional input that your components can accept and allows the components to be dynamic.&lt;br&gt;
Props and State holds information that influences the UI in your browser.&lt;br&gt;
Props is just an object that contains the attributes and their values which has been passed from their parent components.&lt;br&gt;
Props are immutable. Since they are immutable how do we maintain components data that might change over time? The answer lies in using State.&lt;/p&gt;

&lt;p&gt;Components States. &lt;br&gt;
Another way to influence what is rendered on the screen is the state of the components.&lt;/p&gt;

&lt;p&gt;✓Props get passed to the components while state is managed within the component.&lt;br&gt;
✓Props are functions parameters whereas the state are variables declared in the function body.&lt;br&gt;
✓Props immutable Warehouse States can be changed.&lt;br&gt;
✓In functional components props are assessed using the "props" parameter and in-class components using "this.props", where is estate they are assessed using the useState Hook in functional components and "this.state" in class components.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>100daysofcode</category>
    </item>
  </channel>
</rss>
