<?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>Forem: Shilpi Agrawal</title>
    <description>The latest articles on Forem by Shilpi Agrawal (@shilpi230).</description>
    <link>https://forem.com/shilpi230</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%2F454260%2Fb7c12574-eef3-4cec-9cf6-54bb72cfc19b.jpeg</url>
      <title>Forem: Shilpi Agrawal</title>
      <link>https://forem.com/shilpi230</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shilpi230"/>
    <language>en</language>
    <item>
      <title>delegate_to in Rails</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Sun, 11 Oct 2020 16:48:15 +0000</pubDate>
      <link>https://forem.com/shilpi230/delegateto-in-rails-2fc1</link>
      <guid>https://forem.com/shilpi230/delegateto-in-rails-2fc1</guid>
      <description>&lt;p&gt;Ruby is known as Developer's favourite language, for a reason. Why it shouldn't when it makes our life so easier. ❤️&lt;/p&gt;

&lt;p&gt;&lt;code&gt;delegate_to&lt;/code&gt; is another wonderful library, as its name sounds it means delegating your work to someone else. In programmitcal word, provides a delegate class method to easily expose contained objects’ public methods as your own.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;delegate_to&lt;/code&gt; is a very easy to go method with ActiveRecord in Rails. &lt;/p&gt;

&lt;p&gt;The very basic example of how to use it is given below.&lt;/p&gt;

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

&lt;p&gt;Whenever a method is dependent on the presence of another object, we always have the fear of getting &lt;code&gt;NoMethodError&lt;/code&gt; and to solve that &lt;code&gt;delegate_to&lt;/code&gt; has an option of &lt;code&gt;allow_nil&lt;/code&gt; to return nil if object is not present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
  has_one  :profile
  delegate :first_name, to: :profile, allow_nil: true
end
&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;User.new.first_name
&amp;gt;&amp;gt; gives nil if profile is not present.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We could pass more than one method to be delegated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
  has_one  :profile
  delegate :first_name, :age, :last_name, to: :profile, allow_nil: true
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make the delegated method more readable, it comes with an option of &lt;code&gt;prefix&lt;/code&gt; &lt;/p&gt;

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

&lt;p&gt;Hope you like it. And you find it useful for your next method callings. Don't forget to show some love. Thank you.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
    </item>
    <item>
      <title>Password visibility toggle using stimulus.js and Rails 6</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Sun, 04 Oct 2020 19:07:07 +0000</pubDate>
      <link>https://forem.com/shilpi230/password-visibility-toggle-using-stimulus-js-and-rails-6-mb0</link>
      <guid>https://forem.com/shilpi230/password-visibility-toggle-using-stimulus-js-and-rails-6-mb0</guid>
      <description>&lt;p&gt;Recently I wanted to implement password show hide feature in devise forms using Stimulus.js in Rails 6. Being a beginner in stimulus. I had to struggle a lot to find a right way to do it. &lt;/p&gt;

&lt;p&gt;There are two ways of implementation and two scenarios which I will be covering in this article.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;When you want to implement toggle just in one password field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you want to implement toggle in two password fields for e.g. in signup form we will have two password fields.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I am assuming whoever is reading this they have basic idea of Stimulus.js&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is how my basic devise password field looks like&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;div class="form-group my-4" data-controller="password-toggle"&amp;gt;
 &amp;lt;%= f.label :password %&amp;gt;
 &amp;lt;%= f.password_field :password, autocomplete: "current-password", class: 'form-control p-2 my-2 unhide', placeholder: "Password", "data-target": "password-toggle.unhide"%&amp;gt;
 &amp;lt;a data-action="click-&amp;gt;password-toggle#password" class="password-field-icon-1 far fa-eye-slash"&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are three things which I have added which converts my field into accepting stimulus events.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Defining stimulus controller:&lt;/strong&gt; &lt;code&gt;data-controller="password-toggle"&lt;/code&gt; &lt;code&gt;password_toggle_controller.js&lt;/code&gt; is my stimulus controller file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Defining target field:&lt;/strong&gt; &lt;code&gt;"data-target": "password-toggle.unhide"&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Defining click event:&lt;/strong&gt; Click event to be defined on icon tag. &lt;code&gt;data-action="click-&amp;gt;password-toggle#password"&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, this is how our &lt;code&gt;password_toggle_controller.js&lt;/code&gt; will look like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Controller } from "stimulus";

export default class extends Controller {

  static targets = ["unhide"]

  password(e) {
    if (this.input.type === "password") {
      e.target.classList.remove('fa-eye-slash');
      e.target.classList.add('fa-eye');
      this.input.type = "text";
    } else {
      e.target.classList.remove('fa-eye');
      e.target.classList.add('fa-eye-slash');
      this.input.type = "password";
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The basic idea of this piece of code is, if input field type is &lt;code&gt;password&lt;/code&gt; and you click on visibility icon it will change the field type to &lt;code&gt;text&lt;/code&gt; and toggle the icon and vice versa.&lt;/p&gt;

&lt;p&gt;Now, if this works for you and this is only your requirement then great! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But if your requirement is not this and you want to enable the toggle on both password fields. Then we have to use more of jquery. &lt;/p&gt;

&lt;p&gt;And in my code as I have used &lt;code&gt;SVG&lt;/code&gt; type of icon. &lt;code&gt;e.target&lt;/code&gt; doesn't always gives me correct target to make the changes in icon. This &lt;a href="https://medium.com/@schalkneethling/preventing-svg-from-becoming-the-event-target-3e9c039dfdd0"&gt;article&lt;/a&gt; briefly explains why does click event on &lt;code&gt;SVG&lt;/code&gt; icon behaves like that.&lt;/p&gt;

&lt;p&gt;So, I had to change my way of approaching to this problem.&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;div class="form-group pb-1" data-controller="password-toggle"&amp;gt;
  &amp;lt;label&amp;gt;Password&amp;lt;/label&amp;gt;
  &amp;lt;%= f.password_field :password, autocomplete: "off", class: 'form-control p-2', required: true, placeholder: 'Password' %&amp;gt;
  &amp;lt;a data-action="click-&amp;gt;password-toggle#password" class="password-field-icon-2 far fa-eye-slash"&amp;lt;/a&amp;gt; 
&amp;lt;/div&amp;gt;

&amp;lt;div class="form-group pb-1" data-controller="password-toggle"&amp;gt;
  &amp;lt;label&amp;gt;Password Confirmation&amp;lt;/label&amp;gt;
  &amp;lt;%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control p-2', required: true, placeholder: 'Confirm Password' %&amp;gt;
  &amp;lt;a data-action="click-&amp;gt;password-toggle#password" class="password-field-icon-2 far fa-eye-slash"&amp;gt;     &amp;lt;/a&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As, you can see I removed the &lt;code&gt;data-target&lt;/code&gt; as I am not going to use that, instead I will use the &lt;code&gt;event&lt;/code&gt; object, in my stimulus controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Controller } from "stimulus";

export default class extends Controller {

  password(e) {

    var password_field = $(e.currentTarget).prev("input")[0];
    var icon = $(e.currentTarget).closest("svg")[0];

    if (password_field.type === "password") {
      icon.classList.remove('fa-eye-slash');
      icon.classList.add('fa-eye');
      password_field.type = "text";
    } else {
      icon.classList.remove('fa-eye');
      icon.classList.add('fa-eye-slash');
      password_field.type = "password";
    }
  }
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The basic algo of the code remains same, the only change is how do we fetch the &lt;code&gt;input field&lt;/code&gt; and how do we fetch the &lt;code&gt;icon&lt;/code&gt;. Instead of using &lt;code&gt;e.target&lt;/code&gt; I used &lt;code&gt;e.currentTarget&lt;/code&gt; which correctly gives me the icon tag.&lt;/p&gt;

&lt;p&gt;And instead of using &lt;code&gt;this.target&lt;/code&gt; I am using same &lt;code&gt;e.currentTarget&lt;/code&gt; to get the input field just previous to it, which is basically gives me the input password field for that icon event. &lt;/p&gt;

&lt;p&gt;Thank you! For reading it out. I hope it helps someone. If you have better idea than this. Please let me know. I would love implement it in my project. Don't forget to show some love. ❤️&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>stimulus</category>
    </item>
    <item>
      <title>Rails notes 😱</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Sun, 27 Sep 2020 18:22:22 +0000</pubDate>
      <link>https://forem.com/shilpi230/rails-notes-1n23</link>
      <guid>https://forem.com/shilpi230/rails-notes-1n23</guid>
      <description>&lt;p&gt;When I started with Rails, I came across with something called Rails notes. It amazed me how much rails work for developers.&lt;/p&gt;

&lt;p&gt;You just add these tags &lt;code&gt;#TODO&lt;/code&gt;, &lt;code&gt;#FIXME&lt;/code&gt;, &lt;code&gt;#OPTIMIZE&lt;/code&gt; as comments in your files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sIjRcLdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j3zvxhpmn3hahck1hnbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sIjRcLdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j3zvxhpmn3hahck1hnbe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And when you run &lt;code&gt;rails notes&lt;/code&gt; you will get something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OhQS1_nm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/puyec3b0koc4kw40zr5c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OhQS1_nm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/puyec3b0koc4kw40zr5c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The default tags it searches for are &lt;code&gt;["OPTIMIZE", "FIXME", "TODO"]&lt;/code&gt; &lt;br&gt;
If you want to add your custom tags, you can add them. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QX4GyZVQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/spga98c3d2anleqfaayv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QX4GyZVQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/spga98c3d2anleqfaayv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And while searching you have to use those tags.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iL2v-1VK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1tva656pxdw8cnvfvxhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iL2v-1VK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1tva656pxdw8cnvfvxhu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading it out ❤️. If you find it helpful, don't forget to drop in your likes and comments.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webdev</category>
    </item>
    <item>
      <title>send() in ruby to call dynamic methods</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Sun, 20 Sep 2020 18:44:03 +0000</pubDate>
      <link>https://forem.com/shilpi230/send-in-ruby-to-call-dynamic-methods-4d30</link>
      <guid>https://forem.com/shilpi230/send-in-ruby-to-call-dynamic-methods-4d30</guid>
      <description>&lt;p&gt;For newbies in Ruby or Rails programming you will find this method &lt;code&gt;.send&lt;/code&gt; being used at many places. You will find many tutorials and blogs explaining what it does and when to use. &lt;/p&gt;

&lt;p&gt;To get myself an idea what is it. I had to go through lot of them. So, anyone who is new to ruby or meta programming. I will tell you a straight away answer what is it.&lt;/p&gt;

&lt;p&gt;.send() is a method in Ruby to call any method without knowing its name. In your day to day coding you will have mainly two usage of it. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Method Calls:&lt;/strong&gt; If you want to call any dynamic method instead of writing if-else logic again and again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Private Method Calls:&lt;/strong&gt; If you really really want to call a private method. Its been called private method for a reason. So, don't use it for hack around. Use it only when its really needed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;.send&lt;/code&gt; excepts first argument as method name and later if their is an argument to be passed to that method.&lt;/p&gt;

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

&lt;p&gt;So, instead of writing like this in above 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 word == "awful"
 puts "Claw-ful"
elsif word == "perfect"
 puts "Purr-fect"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can use the above code using &lt;code&gt;.send&lt;/code&gt;. This is just short and simple code, but it might be useful when you have tidy if else logics in your code.&lt;/p&gt;

&lt;p&gt;If you find it helpful. Don't forget to drop some loves and comments. Thanks!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>webdev</category>
      <category>rails</category>
    </item>
    <item>
      <title>One liner to fetch the value from hash in Ruby.</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Sat, 12 Sep 2020 15:13:38 +0000</pubDate>
      <link>https://forem.com/shilpi230/one-liner-to-fetch-the-value-from-hash-53ki</link>
      <guid>https://forem.com/shilpi230/one-liner-to-fetch-the-value-from-hash-53ki</guid>
      <description>&lt;p&gt;Struggling with fetching values from nested hash and looking for one liner, to get the work done. &lt;br&gt;
Here, is something really fun I have found. Have a look at it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x6AQ5iXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vcteumbldueit848e9b8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x6AQ5iXP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vcteumbldueit848e9b8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have fun using it. And don't forget to drop some love and comment. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
    </item>
    <item>
      <title>Integrating ActivityNotification &amp; bootstrap_email in Rails 5+</title>
      <dc:creator>Shilpi Agrawal</dc:creator>
      <pubDate>Tue, 01 Sep 2020 15:56:52 +0000</pubDate>
      <link>https://forem.com/shilpi230/setting-up-activitynotification-and-bootstrapemail-in-rails-5-m9m</link>
      <guid>https://forem.com/shilpi230/setting-up-activitynotification-and-bootstrapemail-in-rails-5-m9m</guid>
      <description>&lt;p&gt;Recently in our platform we started using &lt;a href="https://github.com/simukappu/activity_notification"&gt;activity_notifications&lt;/a&gt; for in-platform notifications and email notifications. But we wanted to use our already styled template files. &lt;/p&gt;

&lt;p&gt;If you are struggling with the same problem, then you have come to right place.&lt;/p&gt;

&lt;p&gt;We figured out a way to integrate &lt;a href="https://bootstrapemail.com/docs/setup"&gt;bootstrap_email&lt;/a&gt; and &lt;a href="https://github.com/simukappu/activity_notification"&gt;activity_notifications&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am going to walk you through with basic setup of activity_notification emails and bootstrap_email and then using bootstrap_email styling for all activity_notifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Setting up ActivityNotification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To setup in-platform notification please follow gem's &lt;a href="https://github.com/simukappu/activity_notification/blob/master/docs/Setup.md#Setup"&gt;documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Setting up Email notification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To setup email notification please follow gem's &lt;a href="https://github.com/simukappu/activity_notification/blob/master/docs/Functions.md#email-notification"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While following the documentation please make sure to include this&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;acts_as_target email: :email, email_allowed: :confirmed_at&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;in your target user model.&lt;/p&gt;

&lt;p&gt;Once these two steps are ready you are good to go to start sending emails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Setting up bootstrap email&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To setup bootstrap for your emails, follow gem's &lt;a href="https://bootstrapemail.com/docs/setup"&gt;documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we have successfully enabled both the libraries in our platform. Now its the time to connect both of them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Using custom mailer for activity_notification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While configuring activity_notification you must have created a config file for it, at &lt;code&gt;config/activity_notification.rb&lt;/code&gt; which defines all the settings of activity_notification. &lt;/p&gt;

&lt;p&gt;Update this below line in &lt;code&gt;config/activity_notification.rb&lt;/code&gt; to use our custom mailer file.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config.mailer = "ActivityNotificationMailer"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;And create a new file at &lt;code&gt;app/mailers/activity_notification_mailer.rb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to use this file to override one of the gem's function to use &lt;code&gt;bootstrap_email&lt;/code&gt; function instead of using &lt;code&gt;devise&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ActivityNotificationMailer &amp;lt; ActivityNotification::Mailer
  layout 'whatever_layout_you_are_using_for_emails'

  def send_mail(headers, fallback = nil)
    begin
      make_bootstrap_mail headers
    rescue ActionView::MissingTemplate =&amp;gt; e
      if fallback.present?
        make_bootstrap_mail headers.merge(template_name: fallback)
      else
        raise e
      end
    end
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this file and TADA you will be experiencing automated bootstrap styled emails getting sent from your platform. &lt;/p&gt;

&lt;p&gt;Thank you for reading it out. Hope someone will find it helpful. And if you are that someone don’t forget to show us some love by giving some reactions and comments. :)&lt;/p&gt;

</description>
      <category>rails</category>
      <category>email</category>
      <category>bootstrap</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
