<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmad Raza on Medium]]></title>
        <description><![CDATA[Stories by Ahmad Raza on Medium]]></description>
        <link>https://medium.com/@therailsrealm?source=rss-af7d542c45fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5pE42uU1I4FNFhFiw62KyQ.png</url>
            <title>Stories by Ahmad Raza on Medium</title>
            <link>https://medium.com/@therailsrealm?source=rss-af7d542c45fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:41:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@therailsrealm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Impact of AI in Modern Business]]></title>
            <link>https://therailsrealm.medium.com/the-impact-of-ai-in-modern-business-5e20beb3c985?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e20beb3c985</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[business]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Sun, 18 Jun 2023 06:30:08 GMT</pubDate>
            <atom:updated>2023-06-18T06:30:08.380Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence (AI) has revolutionized the business landscape, transforming how organizations operate and make decisions. With its ability to analyze vast amounts of data, learn from patterns, and make predictions, AI has become a game-changer for businesses across industries. In this article, we will explore the significant impact of AI on modern businesses and the opportunities it presents.</p><h3>1. Enhanced Efficiency and Productivity</h3><p>AI-powered automation has streamlined various business processes, enabling organizations to achieve higher levels of efficiency and productivity. Tasks that were once time-consuming and labor-intensive can now be automated, allowing employees to focus on more strategic and creative endeavors. From customer service chatbots to automated data analysis, AI has expedited workflows and reduced operational costs.</p><h3>2. Improved Customer Experience</h3><p>AI has transformed the way businesses interact with their customers, delivering personalized and seamless experiences. Chatbots and virtual assistants powered by AI can handle customer inquiries and provide instant support, enhancing customer satisfaction and engagement. AI algorithms can also analyze customer data to offer personalized recommendations, improving cross-selling and upselling opportunities.</p><h3>3. Advanced Data Analysis</h3><p>The abundance of data in today’s business environment can be overwhelming, but AI algorithms excel at analyzing and extracting valuable insights from large datasets. By leveraging AI-powered analytics tools, businesses can uncover hidden patterns, trends, and correlations in their data. This enables informed decision-making, predictive modeling, and the ability to anticipate market trends, giving organizations a competitive edge.</p><h3>4. Enhanced Cybersecurity</h3><p>As businesses increasingly rely on digital systems and data, cybersecurity has become a critical concern. AI plays a pivotal role in detecting and preventing cyber threats in real time. AI algorithms can analyze network traffic, identify anomalies, and flag potential security breaches. Additionally, AI can learn from past incidents and adapt its defense mechanisms, staying one step ahead of cybercriminals.</p><h3>5. Automation of Repetitive Tasks</h3><p>AI enables the automation of repetitive and mundane tasks that do not require human intervention. This frees up valuable time for employees to focus on more strategic, creative, and value-added activities. AI-driven automation can significantly reduce errors and improve overall operational efficiency, from data entry and invoice processing to inventory management.</p><p>In conclusion, the impact of artificial intelligence on modern business is profound. From enhanced efficiency and productivity to improved customer experiences and advanced data analysis, AI is reshaping the way organizations operate and compete in the digital age. Embracing AI technologies and leveraging their potential can unlock new possibilities, drive growth, and ensure long-term success in an increasingly competitive business landscape.</p><p>Remember, the key to successfully harnessing AI lies in striking the right balance between automation and human expertise. By embracing AI as a tool for empowerment and innovation, businesses can unlock their full potential and thrive in the digital era.</p><p><em>Note: This article provides an overview of the impact of AI in modern business and is not an exhaustive analysis of the topic.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e20beb3c985" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication using Devise in Rails 7]]></title>
            <link>https://therailsrealm.medium.com/authentication-using-devise-in-rails-7-2b1b5b89d4b5?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b1b5b89d4b5</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Tue, 06 Jun 2023 04:32:44 GMT</pubDate>
            <atom:updated>2023-06-06T04:32:44.307Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this article, we will explore how to implement authentication in a Rails 7 application using the popular <a href="https://github.com/heartcombo/devise">devise gem</a>. Authentication is a crucial aspect of web development, allowing users to securely access and interact with your application. By following this step-by-step guide, you will learn how to set up devise, configure authentication routes, create user models, and enhance your application with authentication features.</p><h3>Prerequisites</h3><p>Before we dive into the implementation, make sure you have the following set up in your development environment:</p><ul><li>Ruby <em>(version &gt;= 2.7.0)</em></li><li>Rails <em>(version &gt;= 7.0.0)</em></li><li>Bundler gem</li></ul><p>Let’s get started!</p><h3>Step 1: Creating a New Rails Application</h3><p>First, let’s create a new Rails application. Open your terminal and execute the following command:</p><pre>rails new authentication-app<br><br># If you want to use a CSS Framework<br># rails new authentication-app -c [tailwind|bootstrap|bulma|postcss|sass]<br><br>cd authentication-app</pre><h3>Step 2: Adding Devise to the Gemfile</h3><p>Next, let’s add the Devise gem to our application’s Gemfile. Open the Gemfile using a text editor and add the following line:</p><pre>gem &#39;devise&#39;</pre><p>Save the file and run the following command in your terminal to install the gem:</p><pre>bundle install</pre><h3>Step 3: Setting up Devise</h3><p>To set up Devise in our application, we need to run a few generator commands. Execute the following command in your terminal:</p><pre>rails generate devise:install</pre><p>Upon running this command, you will see some instructions in your terminal. I have listed them here so that you don’t have to worry about them 🙂 Just follow the below steps:</p><p><strong>1:</strong> Add the below code in config/environments/development.rb:</p><pre>config.action_mailer.default_url_options = { host: &#39;localhost&#39;, port: 3000 }</pre><p><strong>2:</strong> Devise recommends having a root URL in the application. To do this, we need to generate a controller and a view:</p><pre>rails g controller home index</pre><p>This will generate a controller with the name home and a view index.html.erb.</p><p>Now, add the below route in your config/routes file:</p><pre>root &#39;home#index&#39;</pre><p><strong>3:</strong> Add the below code above &lt;%= yield %&gt; tag in your app/views/layouts/application.html.erb:</p><pre>&lt;p class=&quot;notice&quot;&gt;&lt;%= notice %&gt;&lt;/p&gt;<br>&lt;p class=&quot;alert&quot;&gt;&lt;%= alert %&gt;&lt;/p&gt;</pre><p>This will display the flash notifications.</p><p><strong>4:</strong> To generate views for authentication(login, signup etc.) pages, run the following command:</p><pre>rails g devise:views</pre><h3>Step 4: Creating a User Model</h3><p>Let’s create a User model using Devise. Run the following command:</p><pre>rails generate devise User</pre><p>This will generate a User model with Devise’s authentication features.</p><p>After generating the model, run migrations:</p><pre>rails db:migrate</pre><h3>Step 5: Adding Authentication Links to Views</h3><p>Now, let’s add authentication links to our views. Open your application’s layout file (app/views/layouts/application.html.erb) and paste the following code:</p><pre>&lt;% if user_signed_in? %&gt;<br>  &lt;%= button_to &quot;Sign Out&quot;, destroy_user_session_path, method: :destroy %&gt;<br>&lt;% else %&gt;<br>  &lt;%= link_to &#39;Sign In&#39;, new_user_session_path %&gt;<br>  &lt;%= link_to &#39;Sign Up&#39;, new_user_registration_path %&gt;<br>&lt;% end %&gt;</pre><p>This code will display <strong>“Sign Out”</strong> if the user is signed in, and <strong>“Sign In”</strong> and <strong>“Sign Up”</strong> if the user is not signed in.</p><h3>Last Step: Testing Authentication</h3><p>At this point, we have set up authentication in our Rails application using Devise. You can now start your Rails server (rails server) and navigate to the appropriate routes to test the authentication functionality.</p><h3>Conclusion</h3><p>Congratulations! You have successfully implemented authentication in your Rails 7 application using the Devise gem. With Devise, you can easily handle user registration, sign-in, and sign-out processes. This step-by-step guide should have provided you with a solid foundation to build upon and customize authentication features according to your application’s needs.</p><p>Remember to explore <a href="https://github.com/heartcombo/devise">Devise’s documentation</a> for further customisation options and advanced features.</p><p>Happy coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b1b5b89d4b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Should you use CDN in your Rails app? Is it worth it?]]></title>
            <link>https://therailsrealm.medium.com/should-you-use-cdn-in-your-rails-app-is-it-worth-it-bbc025a0754b?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbc025a0754b</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[speed]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Tue, 25 Apr 2023 06:32:06 GMT</pubDate>
            <atom:updated>2023-04-25T06:32:06.454Z</atom:updated>
            <content:encoded><![CDATA[<p>As websites have become more complex and content-heavy, page load time has become critical to user experience. One solution to speed up page load times is to use a Content Delivery Network (CDN). In this blog post, we’ll discuss what a CDN is, why it’s essential, and whether you should use one in your Rails application.</p><h3>What is a CDN?</h3><p>A CDN is a network of servers distributed around the world that stores cached versions of your website’s static assets, such as images, JavaScript, and CSS files. When a user requests a webpage from your application, the CDN will serve the assets from the server that is closest to the user, reducing the time it takes for the content to be delivered.</p><h3>Why use a CDN?</h3><p>There are several benefits to using a CDN:</p><h4>Faster Page Load Times</h4><p>By serving content from a server that is closer to the user, CDNs can dramatically reduce the time it takes for your website to load. This is especially important for users who are located far away from your application’s server.</p><h4>Reduced Server Load</h4><p>When you use a CDN, your application’s server doesn’t have to serve static assets, which can help reduce server load and improve overall performance.</p><h4>Increased Availability</h4><p>CDNs are designed to handle high volumes of traffic, so they can help ensure that your website remains available during periods of high demand.</p><h4>Improved Security</h4><p>Many CDNs offer additional security features, such as DDoS protection and SSL certificates, that can help protect your website from attacks.</p><h3>Should You Use a CDN in Rails?</h3><p>Whether you should use a CDN in your Rails 7 application depends on a few factors:</p><h4>Size of Your Application</h4><p>If your application is relatively small and doesn’t have a lot of static assets, a CDN might not provide much benefit.</p><h4>Geographical Distribution of Your Users</h4><p>If your application has users located all over the world, a CDN can help ensure that your website loads quickly for everyone.</p><h4>Cost</h4><p>CDNs can be expensive, especially for smaller applications. Be sure to weigh the cost of a CDN against the potential benefits before making a decision.</p><h4>Security</h4><p>If security is a concern, a CDN can offer additional protection for your website.</p><h3>How to Use a CDN in Rails</h3><p>If you decide to use a CDN in your Rails 7 application, you can do so by configuring your web server to serve your static assets from the CDN’s server. You’ll need to provide the CDN with the URL for your assets, and the CDN will handle the rest.</p><h4>Configuring the Asset Host</h4><p>In your config/application.rb file, you can set the config.asset_host variable to the URL for your CDN. For example:</p><pre>config.asset_host = &#39;https://cdn.example.com&#39;</pre><p>This will cause all of your asset tags to use the CDN&#39;s URL.</p><h4>Configuring Rails to Serve Assets</h4><p>If you&#39;re using the default Rails asset pipeline, you&#39;ll need to modify your web server&#39;s configuration to serve your assets from the CDN&#39;s server. If you&#39;re using a web server like Nginx or Apache, you can configure it to serve assets from the CDN by adding the following configuration:</p><pre>location ~ ^/assets/ {<br>  expires 1y;<br>  add_header Cache-Control public;<br><br>  # Set the CDN as the asset host<br>  proxy_set_header Host cdn.example.com;<br><br>  # Serve assets from the CDN<br>  proxy_pass https://cdn.example.com;<br>}</pre><h4>Conclusion</h4><p>In conclusion, using a CDN in Rails 7 can be a great way to improve the performance of your web application. However, it’s important to consider the potential downsides (such as additional complexity and cost) before making a decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbc025a0754b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sidekiq in Rails 7: Background Jobs]]></title>
            <link>https://therailsrealm.medium.com/sidekiq-in-rails-7-background-jobs-5a87e7ba426b?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a87e7ba426b</guid>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[sidekiq]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Sat, 22 Apr 2023 12:15:49 GMT</pubDate>
            <atom:updated>2023-04-22T12:15:49.306Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we’ll explore how to use background jobs with <a href="https://github.com/sidekiq/sidekiq">Sidekiq</a> in Rails 7 to handle long-running tasks, including:</p><ol><li>What are background jobs and why use them</li><li>Setting up Sidekiq in your Rails 7 application</li><li>Creating and running background jobs using Sidekiq</li><li>Debugging and monitoring background jobs with Sidekiq</li></ol><h3>What are Background Jobs and Why Use Them?</h3><p>In Rails, background jobs are used to process long-running tasks asynchronously, such as sending emails, generating reports, or processing large datasets. Rather than blocking the main thread of the application and potentially slowing down the user experience, background jobs allow you to run tasks in the background, freeing up the main thread to handle other requests.</p><p>There are several advantages to using background jobs:</p><ul><li><strong>Improved user experience:</strong> By moving long-running tasks to the background, your users won’t be blocked from using your application while the tasks are being processed.</li><li><strong>Scalability:</strong> Running tasks in the background allows your application to scale more effectively. Since background jobs are typically run on a separate thread, your application can process multiple requests at once.</li><li><strong>Increased reliability:</strong> Background jobs can be retried automatically in case of failure, ensuring that tasks are completed successfully.</li></ul><h3>Setting up Sidekiq in Your Rails 7 Application</h3><p>Sidekiq is a popular background job processing framework for Rails. It uses Redis to manage and process jobs, providing a simple and efficient way to manage background jobs. To use Sidekiq in your Rails 7 application, follow these steps:</p><ol><li>Add the sidekiq gem to your Gemfile:</li></ol><pre>gem &#39;sidekiq&#39;</pre><p>2. Run bundle install to install the gem.</p><p>3. Update your config/application.rb file to include the Sidekiq middleware:</p><pre>config.active_job.queue_adapter = :sidekiq</pre><h3>Creating and Running Background Jobs using Sidekiq</h3><p>To create and run background jobs using Sidekiq in Rails 7, follow these steps:</p><ol><li>Create a new job using the rails generate job command:</li></ol><pre>rails generate job MyJob</pre><p>This will create a new job file in the app/jobs directory.</p><p>2. Edit the job file to define the work to be done:</p><pre>class MyJob &lt; ApplicationJob<br>  queue_as :default<br>  <br>  def perform(*args)<br>    # Add your long-running task here<br>  end<br>end</pre><p>3. Start Sidekiq to process the job:</p><pre>bundle exec sidekiq</pre><p>4. Enqueue the job in your application code:</p><pre>MyJob.perform_later(args)</pre><p>This will enqueue the job to the default queue.</p><h3>Debugging and Monitoring Background Jobs with Sidekiq</h3><p>While background jobs can make your application more efficient and responsive, they can also introduce new challenges for debugging and monitoring. Fortunately, Sidekiq provides a simple web interface for monitoring and debugging your background jobs.</p><p>To access the Sidekiq web interface, add the below code in your routes:</p><pre>require &#39;sidekiq/web&#39;<br>mount Sidekiq::Web =&gt; &#39;/sidekiq&#39;</pre><p>Now, start the Sidekiq server by running bundle exec sidekiq in your Rails application&#39;s directory. Then, navigate to <a href="http://localhost:3000/sidekiq">http://localhost:3000/sidekiq</a> in your web browser to view the Sidekiq dashboard.</p><p>The dashboard displays information about the Sidekiq server, including the number of currently running and enqueued jobs. You can also view information about individual jobs, such as their status and any errors that occurred.</p><p>In addition to the web interface, Sidekiq provides several other tools for monitoring and debugging your background jobs. For example, you can configure Sidekiq to send email notifications when jobs fail or use the Sidekiq API to retrieve information about your jobs programmatically.</p><h3>Conclusion</h3><p>Read more on <a href="https://sidekiq.org/">Sidekiq’s Official Website</a>.</p><p>In this article, we’ve explored how to use background jobs with Sidekiq in Rails 7. We covered how to install and configure Sidekiq, how to define and enqueue background jobs, and how to monitor and debug your jobs using Sidekiq’s web interface and other tools.</p><p>By using background jobs with Sidekiq, you can improve the performance and responsiveness of your Rails application, while also making it more robust and fault-tolerant. So if you’re not already using background jobs in your Rails applications, give Sidekiq a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a87e7ba426b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speed Up Database Queries: Rails 7]]></title>
            <link>https://therailsrealm.medium.com/speed-up-database-queries-rails-7-fbc5d801904c?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbc5d801904c</guid>
            <category><![CDATA[speed]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 20:29:23 GMT</pubDate>
            <atom:updated>2023-03-11T20:29:23.402Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re building a web application using Ruby on Rails, you might find that your queries are becoming slow as the size of your database grows. One way to improve performance is to use eager loading, which allows you to load associated records upfront instead of making separate queries for each record.</p><h3>Eager Loading</h3><p>Eager loading is a technique that allows you to load associated records in a single query instead of querying the database multiple times. This can significantly improve the performance of your application by reducing the number of database calls.</p><p>For example, let’s say you have a User model that has_many posts. If you were to retrieve all the users and their associated posts, you could use eager loading like this:</p><pre>@users = User.includes(:posts)</pre><p>This will retrieve all the users and their associated posts in a single query, rather than making a separate query for each user’s posts.</p><p><strong>Other Types of Loading</strong></p><p>In addition to eager loading, Rails also provides other types of loading that you can use to optimize your queries:</p><h3>Lazy Loading</h3><p>Lazy loading is the opposite of eager loading. Instead of loading associated records upfront, lazy loading loads them when they are needed. This can be useful when you have a large number of associations and don’t want to load them all at once.</p><pre>@user = User.find(1)<br>@posts = @user.posts # Posts are loaded when called</pre><h3>Preloading</h3><p>Preloading is similar to eager loading, but instead of joining the associated records in a single query, it makes a separate query for each association. This can be useful when you need to modify the association’s query, or when the associated records are not needed in every query.</p><pre>@users = User.preload(:posts)</pre><h3>Include vs Joins</h3><p>Both includes and joins can be used for eager loading, but they behave differently, .includes will load the associated records using separate queries, while joins will join the associated records into a single query.</p><pre># Includes<br>@users = User.includes(:posts)<br><br># Joins<br>@users = User.joins(:posts)</pre><p>Use includes when you don’t need the associated records in every query, and joins when you do.</p><h3>Conclusion</h3><p>Optimizing database queries is an important part of building high-performance web applications. Eager loading, lazy loading, preloading, and other types of loading can help you achieve this goal. By understanding these techniques and when to use them, you can improve the performance of your Ruby on Rails application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbc5d801904c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Ruby on Rails on Ubuntu]]></title>
            <link>https://therailsrealm.medium.com/install-ruby-on-rails-on-ubuntu-80a4754046fb?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/80a4754046fb</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[setup-guide]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 17:32:23 GMT</pubDate>
            <atom:updated>2023-03-03T17:33:49.972Z</atom:updated>
            <content:encoded><![CDATA[<p>We will be setting up a Ruby on Rails development environment on Ubuntu 22.04 LTS.</p><h3>Installing Ruby</h3><p>The first step is to install some dependencies for <a href="https://medium.com/@therailsrealm/what-is-ruby-on-rails-6f6e5001f1e0">Ruby and Rails</a>.</p><p>We’re going to start by adding the Node.js and Yarn repositories to our system before installing them.</p><pre>sudo apt install curl<br>curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -<br>curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -<br>echo &quot;deb https://dl.yarnpkg.com/debian/ stable main&quot; | sudo tee /etc/apt/sources.list.d/yarn.list<br><br>sudo apt-get update<br>sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn</pre><p>Next, we’re going to be installing Ruby using a version manager called Rbenv.</p><p>Installing with <strong>rbenv</strong> is a simple two-step process. First, you install <strong>rbenv</strong>, and then <strong>ruby-build</strong>:</p><pre>cd<br>git clone https://github.com/rbenv/rbenv.git ~/.rbenv<br>echo &#39;export PATH=&quot;$HOME/.rbenv/bin:$PATH&quot;&#39; &gt;&gt; ~/.bashrc<br>echo &#39;eval &quot;$(rbenv init -)&quot;&#39; &gt;&gt; ~/.bashrc<br>exec $SHELL<br><br>git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build<br>echo &#39;export PATH=&quot;$HOME/.rbenv/plugins/ruby-build/bin:$PATH&quot;&#39; &gt;&gt; ~/.bashrc<br>exec $SHELL</pre><p>To install Ruby and set the default version, we’ll run the following commands:</p><pre>rbenv install 3.2.1 # Change it with the latest version<br>rbenv global 3.2.1</pre><p>Confirm the default Ruby version matches the version you just installed.</p><pre>ruby -v</pre><p>The last step is to install Bundler.</p><pre>gem install bundler<br><br># After bundler is installed, run this command:<br><br>rbenv rehash</pre><p><a href="https://dev.to/ahmadraza/what-is-ruby-on-rails-5a38">Want to know more about ruby and rails?</a></p><h3>Configuring Git</h3><p>We’ll be using Git for our version control system so we’re going to set it up to match our Github account. If you don’t already have a Github account, make sure to <a href="https://github.com/">register</a>. It will come in handy in the future.</p><p>Replace <strong>name</strong> and <strong>email address</strong> in the following steps, with the ones you used for your Github account.</p><pre>git config --global color.ui true<br>git config --global user.name &quot;YOUR NAME&quot;<br>git config --global user.email &quot;YOUR@EMAIL.com&quot;<br>ssh-keygen -t rsa -b 4096 -C &quot;YOUR@EMAIL.com&quot;</pre><p>The next step is to take the newly generated SSH key and add it to your Github account. You want to copy and paste the output of the following command and <a href="https://github.com/settings/ssh">paste it here</a>.</p><pre>cat ~/.ssh/id_rsa.pub</pre><p>Once you’ve done this, you can check and see if it worked:</p><pre>ssh -T git@github.com</pre><p>You should get a message like this:</p><pre>Hi AhmadR-Coder-max! You&#39;ve successfully authenticated, but GitHub does not provide shell access.</pre><h3>Installing Rails</h3><pre>gem install rails -v 7.0.4.2 # Change it with the latest version</pre><p>Now after installing rails, you need to run the following command to make the rails executable available:</p><pre>rbenv rehash</pre><p>Now that you’ve installed Rails, you can run the rails -v command to make sure you have everything installed correctly:</p><pre>rails -v<br># Rails 7.0.4.2</pre><p>If you get a different result for some reason, quit/close your terminal and restart it. If it still doesn’t work, it means your environment may not be setup properly.</p><p><a href="https://dev.to/ahmadraza/mastering-mvc-with-ruby-on-rails-ohd">Want to start you rails journey?</a></p><h3>Setting Up A Database</h3><p>Rails ships with sqlite3 as the default database. Chances are you won’t want to use it because it’s stored as a simple file on disk. You’ll probably want something more robust like MySQL or PostgreSQL.</p><p>To install MySQL, run the below command:</p><pre>sudo apt-get install mysql-server mysql-client libmysqlclient-dev</pre><p>To install PostgreSQL, run the below command:</p><pre>sudo apt install postgresql-14 libpq-dev</pre><p>The postgres installation doesn’t setup a user for you, so you’ll need to follow these steps to create a user with permission to create databases. Feel free to replace <strong>ahmad</strong> with your username.</p><pre>sudo -u postgres createuser ahmad -s<br><br># If you would like to set a password for the user, you can do the following<br><br>sudo -u postgres psql<br>postgres=# \password ahmad</pre><p><strong>Congratulations</strong> 🎉 your setup is done!</p><p>If you get any errors, don’t hesitate to ask in comments.</p><h4><strong>Thanks for reading!</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80a4754046fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner’s Guide to Indexing]]></title>
            <link>https://therailsrealm.medium.com/beginners-guide-to-indexing-c772b0111bda?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/c772b0111bda</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[speed]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 17:31:49 GMT</pubDate>
            <atom:updated>2023-03-01T17:34:14.621Z</atom:updated>
            <content:encoded><![CDATA[<h3>Beginner’s Guide to Indexing — Optimize your Queries</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjvaBe-o4-EZKsms4NYjEA.png" /><figcaption>lndex</figcaption></figure><h3>What is Index?</h3><p>Indexes are database structures that improve the performance of <strong>search queries</strong>. They work like a phone book index, where you can quickly look up a person’s phone number without having to go through every entry in the book.</p><p>In a similar way, a database index helps to speed up the search for data by creating a sorted reference to the values stored in one or more columns of a table. This makes it faster for the database to retrieve data, which can be especially important for large tables or complex queries.</p><p>So, Whenever a query is executed, the database engine searches the index for the keyword and retrieves the corresponding rows from the table. This process is much faster than scanning the entire table to find the matching rows.</p><h3>Drawbacks of Indexes</h3><p>Indexes can significantly improve query performance, but they also have some drawbacks. Creating and maintaining indexes takes time and resources, and they can consume a significant amount of storage space. Additionally, indexes can actually slow down write operations because they need to be updated every time a row is inserted, updated, or deleted.</p><h3>When to use indexes?</h3><p>Here are some examples of when you might want to use an index:</p><ol><li><strong>Primary keys</strong>: When you create a table, you can specify one or more columns as the primary key. This creates a unique index on those columns, which is used to enforce the primary key constraint and ensure that each row has a unique identifier.</li><li><strong>Foreign keys</strong>: When you create a foreign key constraint, the database engine automatically creates an index on the foreign key column(s) in the referencing table. This speeds up queries that join the referencing and referenced tables.</li><li><strong>Frequently searched columns</strong>: If you have a table with a large number of rows and one or more columns that are frequently searched, you can create an index on those columns to speed up those queries.</li><li><strong>Order by and group by clauses</strong>: If your queries frequently include an order by or group by clause, you can create an index on the column(s) being sorted or grouped.</li><li><strong>Where clauses</strong>: If your queries frequently include a where clause that filters the results based on a specific value or range of values, you can create an index on the column(s) being filtered.</li></ol><p>It’s important to note that not all columns need an index. In fact, too many indexes can actually slow down performance because the database engine has to spend more time maintaining them. It’s best to create indexes selectively based on the needs of your queries.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c772b0111bda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Caching in Rails 7: A Must-Read for Every Web Developer]]></title>
            <link>https://therailsrealm.medium.com/the-ultimate-guide-to-caching-in-rails-7-a-must-read-for-every-web-developer-b50d2c1e45ac?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b50d2c1e45ac</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Sat, 25 Feb 2023 10:17:44 GMT</pubDate>
            <atom:updated>2023-02-25T10:20:45.189Z</atom:updated>
            <content:encoded><![CDATA[<p>Caching is an essential technique used to improve the performance of web applications. It helps reduce the time taken to load and serve data by storing frequently accessed data in a fast and easily accessible storage medium, like memory and disk.</p><p>In Ruby on Rails, caching is easier than ever to implement and can have a significant impact on the performance of your web application.</p><p>In this article, we will explore caching in Ruby on Rails 7 and why it’s important.</p><h4>Why is Caching Important?</h4><p>Caching is important because it allows you to avoid performing expensive operations repeatedly.</p><p>For example, if you have a page that displays a list of the <strong>top 10</strong> most popular products on your website, you may need to query your database to retrieve this data. Without caching, this query would be executed <strong>every time</strong> the page is loaded, which could <strong>slow down</strong> page load times and put unnecessary strain on your server.</p><h4>Types of Caching in Ruby on Rails</h4><h4>1. Page Caching</h4><p>Page caching is the simplest form of caching in Rails. It involves caching an entire page as an HTML file, which is served to <strong>subsequent users</strong> who request the same page.</p><blockquote>A <strong>subsequent user</strong> is a user who visits a website after the initial user has already visited it.</blockquote><p>It allows the request for a generated page, to be fulfilled by the web server <em>(i.e. Apache or NGINX)</em> without having to go through the entire Rails stack.</p><p>This is ideal for pages that are mostly static and do not change frequently.</p><h4>2. Action Caching</h4><p>Page Caching cannot be used for actions that have before filters. For example, pages that require authentication.</p><p>This is where Action Caching comes in.</p><p>Action caching is similar to page caching, but instead of caching the entire page, only the action (i.e., the controller method) is cached. It works like <strong>Page Caching</strong> except the incoming web request hits the Rails stack, so that before filters can be run on it before the cache is served.</p><h4>3. Fragment Caching</h4><p>Fragment caching involves caching a small part of a page, such as a sidebar or a comment section. This is useful for pages that have some dynamic content but also contain mostly static content.</p><p>For example, if you wanted to cache each product on a page, you could use this code:</p><pre>&lt;% @products.each do |product| %&gt;<br>  &lt;% cache product do %&gt;<br>    &lt;%= render product %&gt;<br>  &lt;% end %&gt;<br>&lt;% end %&gt;</pre><p>When your application receives its first request to this page, Rails will write a new cache entry with a unique key. A key looks something like this:</p><pre>views/products/index:bea67108094918eeba42cd4a6e786901/products/1</pre><h4>4. Low-Level Caching</h4><p>Low-level caching is a more advanced form of caching that allows you to cache any data that can be represented as an object. This can include data from your database or external APIs.</p><p>Low-level caching is basically dealing with key-value-based caching structures. This is a very commonly used caching type in which the key can be read or written as below:</p><pre>Rails.cache.write(&#39;some-cache-key&#39;, 123)<br>Rails.cache.read(&#39;some-cache-key&#39;) # =&gt; 123<br>Rails.cache.read(&#39;anonymous-cache-key&#39;) # =&gt; nil</pre><h4>Conclusion</h4><p>Caching is a powerful technique that can significantly improve the performance of your Ruby on Rails application. By understanding the different types of caching available and how to implement them, you can create a faster and more responsive user experience for your users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b50d2c1e45ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slack Notifications in Rails 7]]></title>
            <link>https://therailsrealm.medium.com/slack-notifications-in-rails-7-3e51cad5b192?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e51cad5b192</guid>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rails-7]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 10:55:20 GMT</pubDate>
            <atom:updated>2023-02-13T10:55:20.971Z</atom:updated>
            <content:encoded><![CDATA[<p>Wondering how to send a slack notification with your Rails App?</p><p>You have come to the right place!</p><p>With the ability to send notifications to Slack, your Rails App can become even more <strong>dynamic</strong> and <strong>effective</strong>.</p><p>There are many common use cases for Slack notifications, including:</p><ul><li>Keeping track of new user sign-ups</li><li>Monitoring system errors and exception notifications</li><li>Reporting real-time progress of background jobs</li><li>Notifying stakeholders of key events, such as a successful deployment</li><li>Sharing updates and changes in your project</li><li>Keeping the team informed of important deadlines or tasks</li></ul><p>And many more…..</p><h3>Setup the Slack App</h3><ul><li>Firstly you need to create a Slack app from <a href="https://api.slack.com/apps">https://api.slack.com/apps</a>. Click on the <strong>Create New App</strong> button to create a new App:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*GFUAh1qRte5mUCya.png" /></figure><ul><li>Select <strong>From Scratch</strong> option in the modal/popup.</li><li>Type a name for your app such as: “My First App”, and select your workspace.</li><li>Activate Incoming Webhooks for your slack app. By clicking the following option, you’ll see a page where you can activate it:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*W2udjoxPmT0IYYmb.png" /></figure><ul><li>Click the <strong>“Add New Webhook to Workspace”</strong> button at the end of the page. And select a channel where messages will be posted.</li><li>Copy the webhook URL:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*1CzDY29An-I-rGbw.png" /></figure><h3>Setup Integration in Ruby on Rails</h3><p>To send slack notifications, we are going to use a gem called <a href="https://rubygems.org/gems/slack-notifier">slack-notifier</a>.</p><p>So just add it in your Gemfile:</p><pre>gem &#39;slack-notifier&#39;, &#39;~&gt; 2.4&#39; # Change it with the latest version</pre><p>And run:</p><pre>bundle install</pre><p>Now run rails c in your terminal and type:</p><pre>notifier = Slack::Notifier.new &quot;WEBHOOK_URL&quot;,<br>           channel: &quot;#random&quot;,<br>           username: &quot;notifier&quot;</pre><pre>notifier.ping &quot;Hello random&quot;<br># =&gt; will ping the &quot;#random&quot; channel</pre><p>To get more information about the gem, you can visit <a href="https://github.com/slack-notifier/slack-notifier">this</a> url.</p><p><strong>So go ahead and give it a try! And if you get stuck, don’t hesitate to reach out</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e51cad5b192" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker for Beginners]]></title>
            <link>https://therailsrealm.medium.com/introduction-8eef8b06a828?source=rss-af7d542c45fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/8eef8b06a828</guid>
            <category><![CDATA[easy]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Ahmad Raza]]></dc:creator>
            <pubDate>Sun, 12 Feb 2023 18:31:01 GMT</pubDate>
            <atom:updated>2023-02-13T08:13:54.193Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Hey there! Are you curious about <strong>Docker</strong>, but have no idea what it is or how it works? No worries, you’re not alone! Many people feel overwhelmed by the idea of learning a new technology, especially when it comes to DevOps.</p><p><strong>But trust me, Docker is actually a pretty simple concept.</strong></p><h3>What is Docker?</h3><p>Docker is a game-changer in the world of software development. It makes it easy for developers to create, deploy, and run applications in containers, without worrying about the underlying infrastructure. In this article, we will take a beginner-friendly approach to understanding and using Docker.</p><p>A container is a lightweight, standalone, and executable software package that includes everything needed to run an application, including the code, runtime, libraries, and system tools. Think of containers like a shipping container for your code.</p><p>Just like how a shipping container protects your belongings from the elements, a software container protects your code from the complexities of the underlying infrastructure.</p><h3>Why use Docker?</h3><p>Docker has become a popular tool in the world of software development because it provides several benefits, including:</p><ul><li><strong>Portability</strong>: Docker containers can run on any operating system and any infrastructure, making it easy to move your application from development to production.</li><li><strong>Isolation</strong>: Each container runs in its own isolated environment, which helps prevent conflicts between different applications and reduces the risk of security vulnerabilities.</li><li><strong>Reproducibility</strong>: Docker containers ensure that your application will always run the same way, no matter where it is deployed.</li></ul><h3>How to Use Docker</h3><p>So, how do you actually use Docker? Well, it starts with creating a Dockerfile. A Dockerfile is like a recipe that tells Docker how to build your application. Once you have your Dockerfile, you can use the docker build command to create an image of your application.</p><p>Then, you can use the docker run command to start a container from that image. You can even use the docker compose command to manage multiple containers at once.</p><p>And that’s basically it! Of course, there are a lot more details to learn about Docker, but these are the basics.</p><h3>Getting Started with Docker</h3><p>Now that you have a basic understanding of what Docker is and why it’s useful, let’s dive into how you can start using it.</p><ol><li>First you need to install Docker on your computer. You can download Docker for free from the <a href="https://www.docker.com/products/docker-desktop/">official website</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*-n_qWczI6yI7CvPN.png" /></figure><ol><li>Open a terminal or command prompt and run the following command to see if Docker is installed and working properly:</li></ol><pre>docker run hello-world</pre><p>You should see a message similar to the following:</p><pre>Hello from Docker!<br>This message shows that your installation appears to be working correctly.</pre><h3>Conclusion</h3><p>So there you have it! Docker is a simple and powerful platform that makes it easier to manage your applications. Whether you’re a beginner or an experienced developer, learning Docker is definitely worth your time.</p><p>So go ahead and give it a try! And if you get stuck, don’t hesitate to reach out to the Docker community for help. They’re a friendly and helpful bunch!</p><p>Get Started with Docker Today! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8eef8b06a828" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>