<?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: Hrishi Mittal</title>
    <description>The latest articles on Forem by Hrishi Mittal (@hrishio).</description>
    <link>https://forem.com/hrishio</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%2F27240%2F06c84b8c-a38d-4f6f-a2ff-64d8ab1345b7.jpg</url>
      <title>Forem: Hrishi Mittal</title>
      <link>https://forem.com/hrishio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hrishio"/>
    <language>en</language>
    <item>
      <title>What is the difference between include and extend in Ruby?</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Thu, 23 Jan 2025 16:25:42 +0000</pubDate>
      <link>https://forem.com/hrishio/what-is-the-difference-between-include-and-extend-in-ruby-m70</link>
      <guid>https://forem.com/hrishio/what-is-the-difference-between-include-and-extend-in-ruby-m70</guid>
      <description>&lt;h3&gt;
  
  
  This lesson is from &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=what-is-the-difference-between-include-and-extend-in-ruby" rel="noopener noreferrer"&gt;Full Stack Rails Mastery&lt;/a&gt;.
&lt;/h3&gt;

&lt;p&gt;In Ruby, &lt;strong&gt;include&lt;/strong&gt; and &lt;strong&gt;extend&lt;/strong&gt; are two &lt;strong&gt;Module methods&lt;/strong&gt; that allow you to share functionality between classes, but they do so in subtly different ways.&lt;br&gt;&lt;br&gt;This can lead to confusion, especially in a Rails context where both are commonly used.&lt;br&gt;&lt;br&gt;In short: &lt;strong&gt;Use &lt;/strong&gt;include&lt;strong&gt; for instance-level behaviour and &lt;/strong&gt;extend&lt;strong&gt; for class-level functionality&lt;/strong&gt;.This article looks at include and extend in detail, breaking down their differences and providing real-world examples from Rails applications to help you decide when to use each. &lt;strong&gt;The Basics of include and extend&lt;/strong&gt;  &lt;strong&gt;include:&lt;/strong&gt; When you &lt;em&gt;include&lt;/em&gt; a module, its methods become &lt;strong&gt;instance methods&lt;/strong&gt; of the including class. This means every instance of the class gains access to the module’s methods. &lt;br&gt;&lt;br&gt;Example: &lt;/p&gt;
&lt;pre&gt;module Greetable&lt;br&gt;
  def greet&lt;br&gt;
    "Hello!"&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;class User&lt;br&gt;
  include Greetable&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;user = User.new&lt;br&gt;
puts user.greet  # Outputs "Hello!"&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;&lt;strong&gt;extend: &lt;/strong&gt;When you extend a module, its methods become &lt;strong&gt;class methods&lt;/strong&gt; of the extending class (or object). This means the methods are available on the class itself, not its instances. &lt;br&gt;&lt;br&gt;Example: &lt;pre&gt;module Greetable&lt;br&gt;
  def greet&lt;br&gt;
    "Hello!"&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;class User&lt;br&gt;
  extend Greetable&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;puts User.greet  # Outputs "Hello!"&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;&lt;strong&gt;Using extend on individual objects&lt;/strong&gt;You can also use extend by calling it on an object. In our example above, if we didn't include the Greetable module in the User class, we can still run this on a User object like this: &lt;pre&gt;module Greetable&lt;br&gt;
  def greet&lt;br&gt;
    "Hello!"&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;user = User.new&lt;br&gt;
user.extend(Greetable)&lt;/p&gt;

&lt;p&gt;puts user.greet  # Outputs "Hello!"&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;When you call extend on an &lt;strong&gt;object&lt;/strong&gt; (rather than a class), the methods from the module are added as &lt;strong&gt;singleton methods&lt;/strong&gt; to that specific object. This allows you to modify the behaviour of individual objects dynamically, without affecting the class or other instances. &lt;br&gt;&lt;br&gt; Here:     1.  extend adds the greet method to &lt;em&gt;this specific user object&lt;/em&gt;.     2.  Other instances of User remain unaffected: &lt;pre&gt;another_user = User.new&lt;br&gt;
another_user.greet  # Raises a NoMethodError&lt;/pre&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Real-Life Use Cases in Rails&lt;/strong&gt; Let’s explore common scenarios in Rails where include and extend are used effectively. &lt;strong&gt;1. Using &lt;/strong&gt;extend&lt;strong&gt;: Class-Level Behaviour&lt;/strong&gt; &lt;strong&gt;Example: Adding user-friendly ids and slugs to a Model with the FriendlyId gem&lt;/strong&gt;&lt;pre&gt;class Article &amp;lt; ApplicationRecord&lt;br&gt;
  extend FriendlyId&lt;br&gt;
  friendly_id :title, use: [:slugged, :history, :finders]&lt;br&gt;
end&lt;/pre&gt;
&lt;br&gt;Here, extend is used because FriendlyId provides methods like friendly_id that operate at the &lt;strong&gt;class level&lt;/strong&gt;, configuring how slugs are generated and handled for the entire model. &lt;strong&gt;Other Examples:&lt;/strong&gt;    • Enumerize for defining enumerated attributes.   • Utility methods for querying or filtering records (Searchable module). &lt;br&gt; &lt;strong&gt;2. Using &lt;/strong&gt;include&lt;strong&gt;: Instance-Level Behaviour&lt;/strong&gt; &lt;strong&gt;Example: Adding Background Job Functionality with Sidekiq::Job &lt;/strong&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;class AddUserToMailingListJob&lt;br&gt;
  include Sidekiq::Job

&lt;p&gt;def perform(user_id)&lt;br&gt;
    user = User.find(user_id)&lt;br&gt;
    MailingList.add(user.email)&lt;br&gt;
  end&lt;br&gt;
end&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;Here, include is used because Sidekiq::Job provides methods that operate on &lt;strong&gt;instances&lt;/strong&gt; of the job class. Sidekiq creates a new instance of AddUserToMailingListJob for each job execution.  &lt;strong&gt;Other Examples:&lt;/strong&gt;  • &lt;strong&gt;Models:&lt;/strong&gt; Adding reusable instance methods (e.g., Taggable for tags).    • &lt;strong&gt;Controllers:&lt;/strong&gt; Sharing logic via concerns (e.g., authentication filters). &lt;br&gt;&lt;br&gt;&lt;strong&gt;Key Scenarios with Code Examples&lt;/strong&gt; &lt;strong&gt;Scenario 1: Sharing Class-Level Utility Methods&lt;/strong&gt; &lt;pre&gt;module Searchable&lt;br&gt;
  def search_by_name(name)&lt;br&gt;
    where("name LIKE ?", "%#{name}%")&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;class Product &amp;lt; ApplicationRecord&lt;br&gt;
  extend Searchable&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;Product.search_by_name("Gadget")  # Class-level behaviour&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;Here, extend makes the search_by_name method available to the Product class for querying records. &lt;strong&gt;Scenario 2: Adding Reusable Instance Methods&lt;/strong&gt; &lt;pre&gt;module Taggable&lt;br&gt;
  def tags_list&lt;br&gt;
    tags.map(&amp;amp;:name).join(", ")&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;class Post &amp;lt; ApplicationRecord&lt;br&gt;
  include Taggable&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;post = Post.new&lt;br&gt;
puts post.tags_list  # Instance-level behaviour&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;Here, include allows each instance of Post to access tags_list, which operates on instance-specific data. &lt;strong&gt;Scenario 3: Reusable Controller Logic&lt;/strong&gt; &lt;pre&gt;module Authenticated&lt;br&gt;
  def authenticate_user&lt;br&gt;
    redirect_to login_path unless current_user&lt;br&gt;
  end&lt;br&gt;
end

&lt;p&gt;class AdminController &amp;lt; ApplicationController&lt;br&gt;
  include Authenticated&lt;br&gt;
  before_action :authenticate_user&lt;br&gt;
end&lt;/p&gt;&lt;/pre&gt;
&lt;br&gt;Here, include adds authentication logic as reusable instance methods for controllers.  &lt;br&gt;&lt;br&gt;Another example is for pagination with the Pagy gem:&lt;pre&gt;class ApplicationController &amp;lt; ActionController::Base&lt;br&gt;
  include Pagy::Backend&lt;br&gt;
end&lt;/pre&gt;
&lt;br&gt;In summary, &lt;strong&gt;use &lt;/strong&gt;include&lt;strong&gt; for instance-level behaviour and &lt;/strong&gt;extend&lt;strong&gt; for class-level functionality&lt;/strong&gt;. By following the examples and guidelines above, you can write cleaner, more maintainable code in your Rails applications. 

&lt;h3&gt;
  
  
  This lesson is from &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=what-is-the-difference-between-include-and-extend-in-ruby" rel="noopener noreferrer"&gt;Full Stack Rails Mastery&lt;/a&gt;.
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>How to use Solid Queue for background jobs in Rails</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Tue, 17 Dec 2024 10:29:36 +0000</pubDate>
      <link>https://forem.com/hrishio/how-to-use-solid-queue-for-background-jobs-in-rails-3m9l</link>
      <guid>https://forem.com/hrishio/how-to-use-solid-queue-for-background-jobs-in-rails-3m9l</guid>
      <description>&lt;h2&gt;
  
  
  This is a video lesson from the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_medium=solidqueue" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;.
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RSI-ohdcK7c"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Solid Queue is the new default way of running background jobs in Rails 8 apps. In this video lesson, I show you how to use Solid Queue with Active Job to send order confirmation emails in an ecommerce app.&lt;/p&gt;

&lt;h3&gt;
  
  
  If you enjoyed this lesson, you'll love the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_medium=solidqueue" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;!
&lt;/h3&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Ruby Quiz</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Tue, 03 Sep 2024 19:00:18 +0000</pubDate>
      <link>https://forem.com/hrishio/ruby-quiz-2502</link>
      <guid>https://forem.com/hrishio/ruby-quiz-2502</guid>
      <description>&lt;p&gt;I just published a new &lt;a href="https://learnetto.com/ruby-quiz?utm_source=devto&amp;amp;utm_campaign=rubyquiz" rel="noopener noreferrer"&gt;Ruby Quiz&lt;/a&gt; as part of the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=rubyquiz" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are 10 questions randomly sampled from a bigger set, so every time you reload the page, you will get a different quiz. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/ruby-quiz?utm_source=devto&amp;amp;utm_campaign=rubyquiz" rel="noopener noreferrer"&gt;​Take the quiz&lt;/a&gt;, share your score and challenge your friends! :)&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>programming</category>
    </item>
    <item>
      <title>Rails 7.2 allow_browser version guard feature</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Sun, 01 Sep 2024 16:01:25 +0000</pubDate>
      <link>https://forem.com/hrishio/rails-72-allowbrowser-version-guard-feature-2ea5</link>
      <guid>https://forem.com/hrishio/rails-72-allowbrowser-version-guard-feature-2ea5</guid>
      <description>&lt;h3&gt;
  
  
  This lesson is from &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=rails-7-2-allow_browser-version-guard-feature" rel="noopener noreferrer"&gt;Full Stack Rails Mastery&lt;/a&gt;.
&lt;/h3&gt;

&lt;p&gt;If you're using Rails 7.2 or above, you might have run into an error like this when using a slightly older browser:&lt;br&gt;&lt;br&gt;&lt;a href="https://d3op8yelmiam9s.cloudfront.net/public/images/2024-08-31/1725088064471-406_unsuppoorted.jpg?content-disposition=attachment" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fd3op8yelmiam9s.cloudfront.net%2Fpublic%2Fimages%2F2024-08-31%2F1725088064471-406_unsuppoorted.jpg" alt="406 Not Acceptable. Your browser is not supported. Please upgrade your browser to continue."&gt;&lt;/a&gt;Your browser is not supported. Please upgrade your browser to continue.&lt;br&gt;In your Rails server logs, you will see:&lt;/p&gt;
&lt;pre&gt;Rendering public/406-unsupported-browser.html&lt;br&gt;
Completed 406 Not Acceptable&lt;/pre&gt;
&lt;br&gt;The Rails server is returning a &lt;strong&gt;406 Not Acceptable&lt;/strong&gt; HTTP code response due to a new feature that allows you to specify which browsers can access your site.&lt;br&gt;&lt;br&gt;The allowed versions are specified in ApplicationController with the &lt;strong&gt;allow_browser&lt;/strong&gt; method. 

&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;ApplicationController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActionController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
  &lt;span class="c1"&gt;# Only allow modern browsers supporting webp images, web push, &lt;/span&gt;
  &lt;span class="c1"&gt;# badges, import maps, CSS nesting, and CSS :has.&lt;/span&gt;

  &lt;span class="n"&gt;allow_browser&lt;/span&gt; &lt;span class="ss"&gt;versions: :modern&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;The default value is set to :modern which refers to the following versions:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;modern: 
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="ss"&gt;safari: &lt;/span&gt;&lt;span class="mf"&gt;17.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;chrome: &lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;firefox: &lt;/span&gt;&lt;span class="mi"&gt;121&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;opera: &lt;/span&gt;&lt;span class="mi"&gt;106&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;ie: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;These versions are from December 2023. &lt;br&gt;&lt;br&gt;You can specify minimum versions for any browser and also whether they apply to all actions or some, using &lt;strong&gt;only&lt;/strong&gt; and &lt;strong&gt;except&lt;/strong&gt;. You can specify versions in ApplicationController and also in individual controllers for finer control.&lt;br&gt;&lt;br&gt;For example, to allow all versions of Chrome and Opera, no versions of "internet explorer" (ie), Safari versions 16.4+ and Firefox 121+:&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;allow_browser&lt;/span&gt; &lt;span class="ss"&gt;versions: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;safari: &lt;/span&gt;&lt;span class="mf"&gt;16.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;firefox: &lt;/span&gt;&lt;span class="mi"&gt;121&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ie: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;To block specific versions for specific controller actions, in addition to those specified in ApplicationController:&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;ProductsController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="n"&gt;allow_browser&lt;/span&gt; &lt;span class="ss"&gt;versions: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;opera: &lt;/span&gt;&lt;span class="mi"&gt;105&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;chrome: &lt;/span&gt;&lt;span class="mi"&gt;119&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;only: :show&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;You can allow all versions by deleting or commenting out the allow_browser line.&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=rails-7-2-allow_browser-version-guard-feature" rel="noopener noreferrer"&gt;Learn to build production apps with Ruby on Rails&lt;/a&gt;.
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>The 80/20 Rule of Rails performance</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Thu, 22 Aug 2024 21:32:25 +0000</pubDate>
      <link>https://forem.com/hrishio/the-8020-rule-of-rails-performance-3en8</link>
      <guid>https://forem.com/hrishio/the-8020-rule-of-rails-performance-3en8</guid>
      <description>&lt;h3&gt;
  
  
  This lesson is from &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=the-80-20-rule-of-rails-performance" rel="noopener noreferrer"&gt;Full Stack Rails Mastery&lt;/a&gt;.
&lt;/h3&gt;

&lt;p&gt;When it comes to speeding up &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=railsperf8020" rel="noopener noreferrer"&gt;&lt;strong&gt;Rails apps&lt;/strong&gt;&lt;/a&gt;, sometimes people get &lt;em&gt;too fancy&lt;/em&gt; and forget the most important &lt;strong&gt;fundamentals&lt;/strong&gt;.&lt;br&gt;​&lt;br&gt;Like most things in life, the Pareto Principle (80/20 rule) applies to Rails performance too:&lt;br&gt;​&lt;br&gt;​&lt;strong&gt;80% of your app's slowness is caused by 20% of slow code or infrastructure.&lt;/strong&gt;​&lt;br&gt;​&lt;br&gt;Now, don't get hung up on the exact numbers - the 80:20 ratio is a ballpark. The real numbers may be 90:10 or 75:25.&lt;br&gt;​&lt;br&gt;The point is: instead of trying to optimise every little detail, &lt;strong&gt;first focus on the big issues&lt;/strong&gt;. The places where you will get the most bang for your buck.&lt;br&gt;​&lt;br&gt;And for most web apps, that's the &lt;strong&gt;DATABASE&lt;/strong&gt;.&lt;br&gt;​&lt;br&gt;Before you do anything complicated like memory profiling or complex caching, &lt;strong&gt;optimise your database queries&lt;/strong&gt;, which means two things:&lt;br&gt;​&lt;br&gt;1. &lt;strong&gt;Add indexes&lt;/strong&gt; (or indices, if you please) to important columns - any columns you use for lookups (using the &lt;strong&gt;where clause&lt;/strong&gt;) or for &lt;strong&gt;sorting records&lt;/strong&gt;.&lt;br&gt;​&lt;br&gt;2. &lt;strong&gt;Avoid N+1 queries&lt;/strong&gt; by eager loading associated records.&lt;br&gt;For example, on Learnetto when I load courses, I also load associated teacher records with includes.&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;courses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Course&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:teacher&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;You can easily detect N+1 queries by looking at your Rails log and looking for multiple similar SQL queries.&lt;br&gt;​&lt;br&gt;Or you can use something like the bullet gem which automatically detects N+1 queries.&lt;br&gt;​&lt;br&gt;​&lt;em&gt;(A word of warning: Once I worked on a large client project and adding this gem started causing mysterious test failures, which had us tearing our hair out. After many hours of poring over stack traces, we realised the gem was the culprit, removed it and the problem went away.)&lt;/em&gt;​&lt;br&gt;​&lt;br&gt;But here too, you must apply the 80/20 rule.&lt;br&gt;Not all N+1 queries are worth eliminating!&lt;br&gt;​&lt;br&gt;If you have a horrible N+1 query on a page of your website that no one ever visits, then it's not worth optimising (yet).&lt;br&gt;​&lt;br&gt;So, &lt;strong&gt;focus on the most popular pages and controller actions&lt;/strong&gt; which your customers are actually touching.&lt;br&gt;​&lt;br&gt;For example, find the top 10 most visited pages on your site from your website analytics and optimise queries for those pages.&lt;br&gt;​&lt;br&gt;Or if you use an App Performance Monitoring (APM) system like New Relic or Scout, you can get better data.&lt;br&gt;​&lt;br&gt;In the New Relic dashboard, under the Transactions tab, you can see a list of &lt;strong&gt;transactions ranked by where users spend the most time&lt;/strong&gt; (or by the slowest response times).&lt;br&gt;​&lt;br&gt;Below is an example from the courses#show transaction for Learnetto:&lt;br&gt;​&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmcusercontent.com%2F9a9a0718a52a4863b0041d355%2Fimages%2F5b41b722-4a31-4c47-9f87-5004e7901bb1.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%2Fmcusercontent.com%2F9a9a0718a52a4863b0041d355%2Fimages%2F5b41b722-4a31-4c47-9f87-5004e7901bb1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;Another source of performance issue I've noticed is &lt;strong&gt;unnecessary gem dependencies&lt;/strong&gt;.Including too many gems or heavy gems that are not really needed can bloat your application and slow down load times.A very common example of an &lt;strong&gt;unnecessary gem is a simple API wrapper for a third party service&lt;/strong&gt;. I've found that 99% of the times, using a generic library for making HTTP calls is more than enough (Net::HTTP library or httparty gem).&lt;br&gt;&lt;br&gt;The most recent example is when I wanted to use the OpenAI API in a fun project for &lt;a href="https://roastagram.lol/?utm_source=devto" rel="noopener noreferrer"&gt;Instagram profile analysis&lt;/a&gt;, I first reached for the ruby-openai gem. When I ran into some configuration issue before I could make my first API call, I decided to switch to httparty. It turned out to be perfectly adequate for my use case. And I was already using it in the project.So regularly audit your Gemfile, remove unused gems, and consider lighter alternatives or custom solutions for heavy gems that are only partially used.&lt;br&gt;​&lt;br&gt;What other low hanging fruit do you first check for when you want to speed up your Rails app?&lt;br&gt;&lt;br&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>performance</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Ruby on Rails API Quiz</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Sun, 18 Aug 2024 10:36:25 +0000</pubDate>
      <link>https://forem.com/hrishio/ruby-on-rails-api-quiz-552o</link>
      <guid>https://forem.com/hrishio/ruby-on-rails-api-quiz-552o</guid>
      <description>&lt;p&gt;Here's a challenging &lt;a href="https://learnetto.com/rails-quiz?utm_source=devto&amp;amp;utm_campaign=railsapiquiz" rel="noopener noreferrer"&gt;API quiz for Rails developers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I posted another quiz here a few days ago.&lt;/p&gt;

&lt;p&gt;This one is updated and more fun! It gives you 10 random questions from a bigger set.&lt;/p&gt;

&lt;p&gt;And at the end you can also see which ones you got wrong and their correct answers.&lt;/p&gt;

&lt;p&gt;See how many questions you can answer correctly and challenge your friends.&lt;/p&gt;

&lt;p&gt;Post your score in the comments!&lt;/p&gt;

&lt;p&gt;If you enjoyed this quiz, check out my &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=railsapiquiz" rel="noopener noreferrer"&gt;Rails course&lt;/a&gt; for more quizzes.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to setup Rails Guides for offline use</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Sat, 03 Aug 2024 10:35:12 +0000</pubDate>
      <link>https://forem.com/hrishio/how-to-setup-rails-guides-for-offline-use-1ho1</link>
      <guid>https://forem.com/hrishio/how-to-setup-rails-guides-for-offline-use-1ho1</guid>
      <description>&lt;h3&gt;
  
  
  This lesson is from &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=how-to-setup-rails-guides-for-offline-use" rel="noopener noreferrer"&gt;Full Stack Rails Mastery&lt;/a&gt;.
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://guides.rubyonrails.org/" rel="noopener noreferrer"&gt;official Ruby on Rails Guides&lt;/a&gt; are an essential part of a working Rails developer's reference library. While it's easy enough to look them up online, it's also a great idea to keep a copy on your computer for easy offline access.&lt;/p&gt;

&lt;p&gt;It comes in handy if you find yourself somewhere with weak or no internet connectivity and need to look something up quickly.&lt;/p&gt;

&lt;p&gt;The guides are inside the Rails repository - &lt;a href="https://github.com/rails/rails/tree/main/guides" rel="noopener noreferrer"&gt;https://github.com/rails/rails/tree/main/guides&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Start by downloading the repo to your machine. You can &lt;a href="https://github.com/rails/rails/archive/refs/heads/main.zip" rel="noopener noreferrer"&gt;download the zipped file&lt;/a&gt; or run one of the following commands on your terminal.&lt;/p&gt;

&lt;p&gt;Using the HTTPS url:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/rails/rails.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git@github.com:rails/rails.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or the Github CLI:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then cd into the directory and install the gem dependencies:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then cd into the guides 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 guides
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake guides:generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That will generate the HTML version of the guides and put them in a new output directory inside the guides directory. You can open output/index.html to see the guides homepage, which links to all the guides.&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%2Fd3op8yelmiam9s.cloudfront.net%2Fpublic%2Fimages%2F2024-02-08%2F1707390867691-guides_index.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%2Fd3op8yelmiam9s.cloudfront.net%2Fpublic%2Fimages%2F2024-02-08%2F1707390867691-guides_index.png" alt="Rails Guides Index"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also specify the HTML format 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;rake guides:generate:html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that this is the Edge version of the guides, since we are generating them from the main branch.&lt;/p&gt;

&lt;p&gt;If you want to generate the guides for a specific Rails version, you can pass RAILS_VERSION as an argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake guides:generate:epub RAILS_VERSION=7.1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you prefer an ebook format to use on your Kindle, Apple Books or other ereader device, you can generate the guides in epub 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;rake guides:generate:epub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fd3op8yelmiam9s.cloudfront.net%2Fpublic%2Fimages%2F2024-02-08%2F1707390916246-rails_guides_epub.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%2Fd3op8yelmiam9s.cloudfront.net%2Fpublic%2Fimages%2F2024-02-08%2F1707390916246-rails_guides_epub.png" alt="Rails Guides EPUB"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the old kindle option for generating .mobi files has been deprecated.&lt;/p&gt;

&lt;p&gt;Some other arguments you can pass are ONLY (if you only want specify specific guides):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake guides:generate ONLY=assoc,migrations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What's cool is that since you have the code for generating the guides, you can customise them any way you like!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ruby on Rails Quiz</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Wed, 31 Jul 2024 08:55:38 +0000</pubDate>
      <link>https://forem.com/learnetto/ruby-on-rails-quiz-29e3</link>
      <guid>https://forem.com/learnetto/ruby-on-rails-quiz-29e3</guid>
      <description>&lt;p&gt;I made a quiz for Rails developers - &lt;a href="https://learnetto.com/rails-quiz?utm_source=devto&amp;amp;utm_campaign=railsquiz" rel="noopener noreferrer"&gt;https://learnetto.com/rails-quiz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How many questions can you answer correctly?&lt;/p&gt;

&lt;p&gt;Post your score in the comments!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>learning</category>
      <category>hotwire</category>
    </item>
    <item>
      <title>How to build an image gallery in Rails with Stimulus</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Mon, 29 Jul 2024 17:53:53 +0000</pubDate>
      <link>https://forem.com/hrishio/how-to-build-an-image-gallery-in-rails-with-stimulus-164a</link>
      <guid>https://forem.com/hrishio/how-to-build-an-image-gallery-in-rails-with-stimulus-164a</guid>
      <description>&lt;h2&gt;
  
  
  This is a video lesson from the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;.
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rrCP6-YoDcE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In this lesson, we’ll create an interactive image gallery for the product page using Stimulus.&lt;/p&gt;

&lt;p&gt;Here we have all the thumbnails of the product’s images and the first one is displayed as a large image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/tutorials/how-to-build-an-image-gallery-in-rails-with-stimulus?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dibz0lngqpn8pj3fu6n.png" alt="Image gallery" width="800" height="528"&gt;&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
We want to be able to click on any thumbnail to see the large version of it above.&lt;/p&gt;

&lt;p&gt;Stimulus is a part of Hotwire. It’s "a modest JavaScript framework for the HTML you already have".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/tutorials/how-to-build-an-image-gallery-in-rails-with-stimulus?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnwckib4c8t85mrfscc3z.png" alt="Hotwire Stimulus" width="800" height="489"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stimulus gives you a lightweight way to add interactivity to webpages.&lt;br&gt;
You start by adding 3 data attributes to your HTML:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;controller&lt;/li&gt;
&lt;li&gt;target&lt;/li&gt;
&lt;li&gt;action&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Stimulus automatically connects DOM elements to JavaScript objects called controllers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The controller is where you define the logic of the interaction.&lt;/p&gt;

&lt;p&gt;In the example on the Stimulus homepage, there's a form with an input text field where you can enter a name. When you click greet, it displays the text “Hello” with the entered name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;data-controller=&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;data-hello-target=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;data-action=&lt;/span&gt;&lt;span class="s"&gt;"click-&amp;gt;hello#greet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Greet
  &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;data-hello-target=&lt;/span&gt;&lt;span class="s"&gt;"output"&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="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;So the first data attribute is &lt;strong&gt;controller&lt;/strong&gt; with the value "&lt;em&gt;hello&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;You set that on the outer div which contains the rest of the UI elements.&lt;/p&gt;

&lt;p&gt;There are two &lt;strong&gt;targets&lt;/strong&gt; - one for input called name and another for the output.&lt;/p&gt;

&lt;p&gt;And there's an &lt;strong&gt;action&lt;/strong&gt; attribute set on the button with the value "&lt;em&gt;click-&amp;gt;hello#greet&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;This means when the button is clicked, call the greet method in the hello controller.&lt;/p&gt;

&lt;p&gt;Now, let’s look at the controller code.&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="c1"&gt;// hello_controller.js&lt;/span&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;stimulus&lt;/span&gt;&lt;span class="dl"&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;name&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;output&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="nf"&gt;greet&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;outputTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="s2"&gt;`Hello, &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;nameTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&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="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;We start by importing the built-in &lt;strong&gt;Controller&lt;/strong&gt; class from Stimulus. We will extend this to define our own hello controller.&lt;br&gt;
import { Controller } from "stimulus"&lt;/p&gt;

&lt;p&gt;export default class extends Controller {&lt;/p&gt;

&lt;p&gt;Note the naming convention here. The file is called &lt;strong&gt;hello_controller.js&lt;/strong&gt;. That’s the controller name followed by "_controller.js". The name hello is what's used as the identifier value for the &lt;strong&gt;data-controller&lt;/strong&gt; attribute on the container div.&lt;/p&gt;

&lt;p&gt;Next we define a list of targets as static properties on the class.&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="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;name&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;output&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Targets map HTML elements to controller properties.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have two targets here - the input name and the output.&lt;/p&gt;

&lt;p&gt;Stimulus will automatically create corresponding properties for each of them - &lt;strong&gt;this.nameTarget&lt;/strong&gt; and &lt;strong&gt;this.outputTarget&lt;/strong&gt; respectively.&lt;/p&gt;

&lt;p&gt;Again, note the naming convention here. this dot the name of the target followed by the word Target with a capital T.&lt;/p&gt;

&lt;p&gt;Finally, we have the greet method definition:&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="nf"&gt;greet&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;outputTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="s2"&gt;`Hello, &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;nameTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backticks mean it’s a template literal, and the dollar curly brackets &lt;strong&gt;${ }&lt;/strong&gt; are used to embed an expression within the string. This is similar to string interpolation in Ruby with hash curly brackets &lt;strong&gt;#{ }&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now that we have the basic idea of how Stimulus works, let’s put it to use by building our very own first Stimulus controller.&lt;/p&gt;

&lt;p&gt;Instead of coding it from scratch, we can use a Rails generator:&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 gallery
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that will create &lt;strong&gt;gallery_controller.js&lt;/strong&gt; in app/javascript/controllers.&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="c1"&gt;// Connects to data-controller="gallery"&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="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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;First we import the Controller class from stimulus and then extend it.&lt;/p&gt;

&lt;p&gt;Stimulus has automatically added a method called connect.&lt;/p&gt;

&lt;p&gt;This is a special method - a &lt;strong&gt;lifecycle callback&lt;/strong&gt;. There are a few of these special methods. connect runs anytime the controller is connected to the DOM.&lt;/p&gt;

&lt;p&gt;To see it in action, let’s add a console log statement that says image gallery controller connected.&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="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="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="s1"&gt;image gallery controller connected&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to define a &lt;strong&gt;data-controller&lt;/strong&gt; attribute so Stimulus knows which DOM element to connect this controller to.&lt;/p&gt;

&lt;p&gt;Let’s go to the product partial (&lt;strong&gt;app/views/products/_product.html.erb&lt;/strong&gt;) and add a data controller attribute to the outermost div. And set its value to gallery.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&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;"min-h-screen py-12 sm:pt-20"&lt;/span&gt; &lt;span class="na"&gt;data-controller=&lt;/span&gt;&lt;span class="s"&gt;"gallery"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Now refresh the page in the browser and we see our log message in the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/tutorials/how-to-build-an-image-gallery-in-rails-with-stimulus?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famaluba1v9p13823kkqw.png" alt="Stimulus controller connected" width="800" height="232"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s set the data-action attribute on the thumbnails. Because that’s what we want to click. We set the action to a method called “display”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;%=&lt;/span&gt; &lt;span class="na"&gt;image_tag&lt;/span&gt; &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;class:&lt;/span&gt; &lt;span class="err"&gt;"&lt;/span&gt;&lt;span class="na"&gt;thumbnail&lt;/span&gt;&lt;span class="err"&gt;",&lt;/span&gt; &lt;span class="na"&gt;data:&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="na"&gt;action:&lt;/span&gt; &lt;span class="err"&gt;"&lt;/span&gt;&lt;span class="na"&gt;click-&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;gallery#display"} %&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Ok, now let’s define this display method in the controller. First, let’s simply console log a message “display clicked image”. So we know our action attribute is working correctly.&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="nf"&gt;display&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="s1"&gt;display clicked image&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s test it in the browser. Refresh and click a thumbnail. And there we have our second console log message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/tutorials/how-to-build-an-image-gallery-in-rails-with-stimulus?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcypvp5q62mi44yauvkt9.png" alt="Gallery display method console log" width="800" height="272"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok now, we need one more data attribute - a target.&lt;/p&gt;

&lt;p&gt;That would be the big image at the top of the gallery. So inside that image tag, let's add data “gallery-target” and we’ll call it “display”.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= image_tag product.images.first, id: "displayed-image", 
              data: { "gallery-target": "display" } %&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;If we refresh and look at the elements in the console, we can see the data attributes we’ve set.&lt;/p&gt;

&lt;p&gt;Ok, now let’s proceed with defining the rest of the controller.&lt;/p&gt;

&lt;p&gt;First, let’s define our static targets. We only need one here called “display”:&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="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;display&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, let’s define the logic of the display method. Let’s remove the console log statement.&lt;/p&gt;

&lt;p&gt;We want to set the value of the src attribute of the display target image.&lt;/p&gt;

&lt;p&gt;So we can write:&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="nf"&gt;display&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;displayTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&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;currentTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember the naming convention here - target name “display” followed by the word Target with a capital T.&lt;/p&gt;

&lt;p&gt;We can get the src of the thumbnail image via “event” i.e. the click event which we used in the data-action attribute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;currentTarget&lt;/strong&gt; is the DOM target on which the data-action attribute is defined. In this case, it’ll be whichever thumbnail image is clicked.&lt;/p&gt;

&lt;p&gt;Ok, now let’s try that in the browser. Refresh and click a different thumbnail And there you go - the big displayed image changes to that one. Try clicking another one and it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/tutorials/how-to-build-an-image-gallery-in-rails-with-stimulus?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz033x7fwr1vc79d309k0.gif" alt="Image gallery working with Stimulus Hotwire" width="755" height="566"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So there you have it - we have created our first Stimulus controller. We were able to create an image gallery with very little code!&lt;/p&gt;

&lt;h3&gt;
  
  
  If you enjoyed this lesson, you'll love the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;!
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=stimulusgallery&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzohrmh79ejcdnjz4mfi.png" alt="Full Stack Rails Mastery course" width="800" height="670"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>hotwire</category>
      <category>stimulus</category>
    </item>
    <item>
      <title>How to deploy a Rails 7 app to Fly.io</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Thu, 25 Jul 2024 09:05:36 +0000</pubDate>
      <link>https://forem.com/hrishio/how-to-deploy-a-rails-7-app-to-flyio-5kh</link>
      <guid>https://forem.com/hrishio/how-to-deploy-a-rails-7-app-to-flyio-5kh</guid>
      <description>&lt;p&gt;This is a video lesson from the &lt;a href="https://learnetto.com/users/hrishio/courses/full-stack-rails-mastery?utm_source=devto&amp;amp;utm_campaign=deploytofly&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;Full Stack Rails Mastery course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Bs0eVlJUhfg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In this 5-minute lesson, you'll learn how to deploy a simple Rails 7 app to Fly.io, a popular web hosting service.&lt;/p&gt;

&lt;p&gt;Some common errors you may run into when deploying to Fly.io:&lt;/p&gt;

&lt;p&gt;500 error on deploy&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58xcx9126f6e36w0g618.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58xcx9126f6e36w0g618.png" alt="Image description" width="400" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get a 500 error on deploy, it may be because the database did not get set up or migrated. You need these lines in your fly.toml file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[deploy]&lt;/span&gt;
  &lt;span class="py"&gt;release_command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'./bin/rails db:prepare'&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Sometimes Fly removes that command, which causes the 500 error.&lt;/p&gt;

&lt;p&gt;Missing assets&lt;/p&gt;

&lt;p&gt;If you find that your CSS is not loading, even though the link tags look fine, it could be because these lines are missing or incorrect in fly.toml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[[statics]]&lt;/span&gt;
  &lt;span class="py"&gt;guest_path&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'/rails/public'&lt;/span&gt;
  &lt;span class="py"&gt;url_prefix&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'/'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's something Fly adds to serve assets directly from its cache (which is not quite a CDN), bypassing your web server. Sometimes the guest path is set to an incorrect value.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>fly</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to write a good resume</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Fri, 14 Jan 2022 15:38:42 +0000</pubDate>
      <link>https://forem.com/hrishio/how-to-write-a-good-resume-30g4</link>
      <guid>https://forem.com/hrishio/how-to-write-a-good-resume-30g4</guid>
      <description>&lt;p&gt;The purpose of a resume is to clearly &lt;strong&gt;convey your top skills and establish credibility&lt;/strong&gt; through past work experience, projects and educational qualifications.&lt;/p&gt;

&lt;p&gt;Start with the audience in mind - &lt;strong&gt;who reads your resume?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recruiter&lt;/li&gt;
&lt;li&gt;Hiring manager&lt;/li&gt;
&lt;li&gt;CTO, Senior Developer, Tech lead, Engineering Manager&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some tips for how to make your resume stand out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mirror the language of the job/role description.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many companies use applicant tracking systems (ATS) - software for automatically scanning and filtering resumes before any human reads them. You need to make sure your resume gets through that by including all the most important keywords relevant to the contract.&lt;/p&gt;

&lt;p&gt;You can also run your resume through an online ATS scanner like &lt;a href="https://www.jobscan.co/"&gt;Jobscan&lt;/a&gt;, which gives you a match score by comparing your resume and job descriptions.&lt;br&gt;
 &lt;br&gt;
But &lt;em&gt;don't take it too literally&lt;/em&gt;. Their algorithm is too simplistic. If you added all the keywords they recommend, your resume would become a list of buzzwords.&lt;/p&gt;

&lt;p&gt;Instead, just look out for any obvious important keywords you're missing and add them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep your resume short - no more than 1–2 pages long.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You only need to provide enough information to get an interview. Avoid including irrelevant projects, certifications or hobbies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use results-oriented active verbs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, try to use words like "shipped", "delivered", and "led" instead of "took part in", "wrote code" or "was part of team".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where possible, quantify the impact of your work.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you can attach any monetary ($) value to your work, make sure to mention it. But keep it real - don't inflate the impact and never lie.&lt;/p&gt;

&lt;p&gt;Make sure to mention any performance improvements you delivered. For example, "Improved website load times by 25% during peak shopping season".&lt;/p&gt;

&lt;p&gt;Or at least mention a qualitative benefit to the business. For example, "simplified onboarding process for new vendors on platform by automating upload of key documents".&lt;/p&gt;

&lt;p&gt;If you led a team, mention how many team members there were.&lt;/p&gt;

&lt;p&gt;If you built some tool used by your employer, mention how many people in the company or how many customers used it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mention the key technologies used.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each line item of work experience, make sure to mention the key tech stacks used. This ties back to the point above about ATS.&lt;/p&gt;

&lt;p&gt;But don't just list lots of programming languages, frameworks and tools without the context in which you used them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use a good simple template.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use a simple one from Google docs or a nicer one from Canva - &lt;a href="https://www.canva.com/resumes/templates/"&gt;https://www.canva.com/resumes/templates/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Avoid using overly fancy non-standard layouts or colour schemes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tailor your resume for each job or contract.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's a bit more of an effort, but you can really stand out if you emphasise parts of your experience that are particularly relevant to a company.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make it easy to scan quickly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bold words throughout your resume to highlight and draw attention to important keywords. No one will read your entire resume, so make it easy to scan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to your important online profiles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the top of the resume, include links to your personal website, Github profile, portfolio, LinkedIn profile and any other relevant professional profiles.&lt;/p&gt;

&lt;p&gt;If your Github profile does not have any relevant projects, then it's better not to link to it. Showing an empty or inactive profile is worse than not showing one.&lt;/p&gt;

&lt;p&gt;Highlight your &lt;strong&gt;strengths&lt;/strong&gt;, &lt;em&gt;not weaknesses&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Highlight your non-coding skills.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Non-technical skills can be very important, especially as a contractor. So make sure to highlight:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;relevant personal projects&lt;/li&gt;
&lt;li&gt;any talks you've given&lt;/li&gt;
&lt;li&gt;articles or videos you've published&lt;/li&gt;
&lt;li&gt;community or leadership initiatives&lt;/li&gt;
&lt;li&gt;experience in mentoring others&lt;/li&gt;
&lt;li&gt;experience in hiring - screening or interviewing candidates&lt;/li&gt;
&lt;li&gt;open source contributions, including documentation and community management&lt;/li&gt;
&lt;li&gt;relevant courses and certifications you have completed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are &lt;strong&gt;doubly important if you don't have enough relevant work experience&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Do you have any other tips or questions? Share them in the comments below.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This lesson is from my &lt;a href="https://learnetto.com/users/hrishio/courses/6-figure-contractor-group-coaching-program?utm_source=DEV&amp;amp;utm_medium=repost&amp;amp;utm_campaign=goodresume"&gt;6-Figure Contractor Group Coaching Program&lt;/a&gt; - a 4-week cohort-based course in which I help developers like you kickstart their careers as contractors. &lt;a href="https://learnetto.com/users/hrishio/courses/6-figure-contractor-group-coaching-program?utm_source=DEV&amp;amp;utm_medium=repost&amp;amp;utm_campaign=goodresume"&gt;Learn more here&lt;/a&gt; and sign up for the next cohort.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>resume</category>
      <category>jobs</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn to make and sell</title>
      <dc:creator>Hrishi Mittal</dc:creator>
      <pubDate>Fri, 07 Jan 2022 18:06:24 +0000</pubDate>
      <link>https://forem.com/hrishio/learn-to-make-and-sell-1cp4</link>
      <guid>https://forem.com/hrishio/learn-to-make-and-sell-1cp4</guid>
      <description>&lt;p&gt;Making and selling are the two most valuable skills you can master this year.&lt;/p&gt;

&lt;p&gt;And I mean making and selling in the broadest terms.&lt;/p&gt;

&lt;p&gt;As a developer, making comes naturally to you. But in addition to making software, I also mean making other things - music, stories, furniture, paintings.&lt;/p&gt;

&lt;p&gt;As a developer, you might not be keen on selling. But I'm not talking about the cliched image of a used car salesman.&lt;/p&gt;

&lt;p&gt;By selling, I mean presenting yourself well and convincing others to use your services or products.&lt;/p&gt;

&lt;p&gt;For example, if you're looking for a new job this year. Or starting out as a freelancer. You will need to learn to sell yourself.&lt;/p&gt;

&lt;p&gt;So, the new theme for my startup &lt;a href="https://learnetto.com/?utm_source=DEV&amp;amp;utm_medium=repost&amp;amp;utm_campaign=makeandsell"&gt;Learnetto&lt;/a&gt; this year is to help you learn to make and sell.&lt;/p&gt;

&lt;p&gt;Look out for lots of great new content on both those topics.&lt;/p&gt;

&lt;p&gt;Make sure you &lt;a href="https://learnetto.com/newsletter?utm_source=DEV&amp;amp;utm_medium=repost&amp;amp;utm_campaign=makeandsell"&gt;sign up to our newsletter&lt;/a&gt; to get the latest content first.&lt;/p&gt;

&lt;p&gt;Happy new year!&lt;/p&gt;

&lt;p&gt;PS Btw, are you interested in teaching? I'm looking for people to help me create new educational content (tutorials, videos, workshops) on Learnetto. Email me at &lt;a href="mailto:hrishi@learnetto.com"&gt;hrishi@learnetto.com&lt;/a&gt; and tell me what you can teach. If you have any examples, then please include some links to your work.&lt;/p&gt;

</description>
      <category>career</category>
    </item>
  </channel>
</rss>
