<?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: Karan Mehta</title>
    <description>The latest articles on Forem by Karan Mehta (@karanm645).</description>
    <link>https://forem.com/karanm645</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%2F973168%2Fb13d1ca2-2411-45ae-a96e-5732e326c790.png</url>
      <title>Forem: Karan Mehta</title>
      <link>https://forem.com/karanm645</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/karanm645"/>
    <language>en</language>
    <item>
      <title>Crafting my Code Chronicles Blog</title>
      <dc:creator>Karan Mehta</dc:creator>
      <pubDate>Fri, 16 Feb 2024 17:26:43 +0000</pubDate>
      <link>https://forem.com/karanm645/crafting-my-code-chronicles-blog-1ec9</link>
      <guid>https://forem.com/karanm645/crafting-my-code-chronicles-blog-1ec9</guid>
      <description>&lt;p&gt;Creating my blog was an amazing learning experience, highlighting the importance of thoughtful planning and incorporating valuable resources. Previously, my approach lacked a Minimum Viable Product (MVP), resulting in a chaotic blog. However, with insights from senior engineers and resources from Chris at GoRails, I embarked on a journey to reconstruct and document the technical process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Structure:&lt;/strong&gt;&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%2Fro7p2iz6kott76y8xmw2.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%2Fro7p2iz6kott76y8xmw2.png" alt="Descriptive DB Design" width="800" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scopes for Dynamic Content Sorting&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  def draft?
    published_at.nil?
  end 

  def published?
    published_at? &amp;amp;&amp;amp; published_at &amp;lt;= Time.current
  end 

  def scheduled?
    published_at? &amp;amp;&amp;amp; published_at &amp;gt; Time.current
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then used ActiveRecord to query these methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  scope :sorted, -&amp;gt; { order(arel_table[:published_at].desc.nulls_first).order(updated_at: :desc) }
  scope :draft, -&amp;gt; { where(published_at: nil)}
  scope :published, -&amp;gt; { where("published_at &amp;lt;= ?", Time.current)}
  scope :scheduled, -&amp;gt; { where("published_at &amp;gt; ?", Time.current)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Utilizing these scopes in my model facilitated seamless handling of different scenarios based on the user's sign-in status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  def index 
    if user_signed_in?
      @blog_posts = BlogPost.all.sorted
      @pagy, @blog_posts = pagy(@blog_posts)
    else
      @blog_posts = BlogPost.published.sorted
      @pagy, @blog_posts = pagy(@blog_posts)
    end 
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Design&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The design phase, powered by Tailwind CSS, was a thrilling endeavor. Investing time in envisioning the blog's appearance through sketches laid the groundwork for a visually appealing and user-friendly interface. One thing I noticed with Tailwind CSS is that the code seems packed and congested which may cause confusion when wanting to change it. For now, it's a tool that is really handy till I master Javascript and the frameworks that power it.&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%2Fxku6zw8e5t0nekbus770.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%2Fxku6zw8e5t0nekbus770.png" alt="Tailwind CSS snippet" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Organization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub Projects emerged as a pivotal tool for orchestrating tasks. This approach, inspired by agile methodologies, involved breaking down the project into phases and manageable tickets. From noting scenarios and creating user stories to task breakdowns within sprints, the agile workflow streamlined the development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Languages and Framework&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ruby - 3.2.2&lt;/li&gt;
&lt;li&gt;Rails - 7.0.4.3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Database&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Gems&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;li&gt;Devise for Authentication and Authorization&lt;/li&gt;
&lt;li&gt;Pagy for Pagination&lt;/li&gt;
&lt;li&gt;RSpec for Testing&lt;/li&gt;
&lt;li&gt;Launchy&lt;/li&gt;
&lt;li&gt;Orderly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, my blog transformation journey encompassed a robust database structure, elegant design with Tailwind CSS, and an organized project management approach via GitHub Projects.&lt;/p&gt;

&lt;p&gt;As I update this blog with more features, I'll dive deeply into  techniques I use and my overall experiences as a developer.&lt;/p&gt;

&lt;p&gt;Here is the site: &lt;a href="https://karans-blog.onrender.com/"&gt;Karan's Blog&lt;/a&gt; -- Feedback is always welcome, please shoot me an e-mail at: &lt;a href="mailto:karanm645@gmail.com"&gt;karanm645@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>ruby</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
