<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Samala Sumanth</title>
    <description>The latest articles on DEV Community by Samala Sumanth (@samalasumanth0262).</description>
    <link>https://dev.to/samalasumanth0262</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%2F444339%2F694bd415-2c5c-4119-a256-26fc61c20e8d.jpeg</url>
      <title>DEV Community: Samala Sumanth</title>
      <link>https://dev.to/samalasumanth0262</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samalasumanth0262"/>
    <language>en</language>
    <item>
      <title>Grape GEM in Ruby on Rails: Handling User Model and API Endpoint</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Sun, 18 Jun 2023 20:34:48 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/grape-gem-in-ruby-on-rails-handling-user-model-and-api-endpoint-g6d</link>
      <guid>https://dev.to/samalasumanth0262/grape-gem-in-ruby-on-rails-handling-user-model-and-api-endpoint-g6d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
           In the world of Ruby on Rails, developers are often faced with the challenge of building robust and scalable APIs. One powerful tool that comes to the rescue is the Grape gem. &lt;br&gt;
           Grape provides a simple and efficient way to create APIs in Ruby, and in this blog, we will explore how to leverage Grape for handling the User Model in a Ruby on Rails application. Specifically, we will focus on creating an API endpoint for managing users at &lt;code&gt;api/v1/users&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Grape?&lt;/strong&gt;&lt;br&gt;
           Grape is a micro-framework for creating APIs in Ruby. It is designed to be lightweight, modular, and highly customisable. Grape integrates seamlessly with Ruby on Rails applications, making it an excellent choice for building APIs. With Grape, you can define endpoints, handle requests and responses, and even generate documentation effortlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up Grape in Ruby on Rails:&lt;/strong&gt;&lt;br&gt;
           To begin, make sure you have a Ruby on Rails application set up. You can create a new Rails application by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;rails&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;my_app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add the Grape gem to your application's Gemfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'grape'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the Grape gem, run &lt;code&gt;bundle install&lt;/code&gt; to install the gem and its dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the User Model:&lt;/strong&gt;&lt;br&gt;
      In this example, we will assume that you already have a User model in your Rails application. If you don't, you can generate one using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;rails&lt;/span&gt; &lt;span class="n"&gt;generate&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="ss"&gt;:string&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="ss"&gt;:string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After generating the User model, run the migration using &lt;code&gt;rails db:migrate&lt;/code&gt; to create the corresponding table in the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing the User API Endpoint:&lt;/strong&gt;&lt;br&gt;
Now it's time to create the API endpoint for managing users. In your Rails application's &lt;code&gt;app/api&lt;/code&gt; directory, create a new file named &lt;code&gt;v1/users.rb&lt;/code&gt;. This file will contain the Grape endpoint definition for the users API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;V1&lt;/span&gt;
  &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Users&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;Grape&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;API&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="s1"&gt;'v1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;using: :path&lt;/span&gt;
    &lt;span class="nb"&gt;format&lt;/span&gt; &lt;span class="ss"&gt;:json&lt;/span&gt;

    &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="ss"&gt;:users&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s1"&gt;'Return a list of users'&lt;/span&gt;
      &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s1"&gt;'Return a specific user'&lt;/span&gt;
      &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;requires&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User ID'&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="n"&gt;route_param&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
          &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s1"&gt;'Create a new user'&lt;/span&gt;
      &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;requires&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User name'&lt;/span&gt;
        &lt;span class="n"&gt;requires&lt;/span&gt; &lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User email'&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="n"&gt;post&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="ss"&gt;email: &lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s1"&gt;'Update an existing user'&lt;/span&gt;
      &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;requires&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User ID'&lt;/span&gt;
        &lt;span class="n"&gt;optional&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User name'&lt;/span&gt;
        &lt;span class="n"&gt;optional&lt;/span&gt; &lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User email'&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="n"&gt;put&lt;/span&gt; &lt;span class="s1"&gt;':id'&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="ss"&gt;email: &lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s1"&gt;'Delete a user'&lt;/span&gt;
      &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;requires&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;desc: &lt;/span&gt;&lt;span class="s1"&gt;'User ID'&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="n"&gt;delete&lt;/span&gt; &lt;span class="s1"&gt;':id'&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;destroy&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code defines the /api/v1/users endpoint with various HTTP methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET /api/v1/users - Returns a list of all users.&lt;/li&gt;
&lt;li&gt;GET /api/v1/users/:id - Returns a specific user based on the provided :id.&lt;/li&gt;
&lt;li&gt;POST /api/v1/users - Creates a new user with the given parameters.&lt;/li&gt;
&lt;li&gt;PUT /api/v1/users/:id - Updates an existing user with the provided :id.&lt;/li&gt;
&lt;li&gt;DELETE /api/v1/users/:id - Deletes a user with the given :id.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Mounting the User API Endpoint:&lt;/strong&gt;&lt;br&gt;
To make the User API endpoint accessible, you need to mount it in your Rails application. Open the &lt;code&gt;config/routes.rb&lt;/code&gt; file and add the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;mount&lt;/span&gt; &lt;span class="no"&gt;V1&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Users&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'/api/v1/users'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line instructs the Rails application to map the &lt;code&gt;/api/v1/users&lt;/code&gt; URL path to the &lt;code&gt;V1::Users&lt;/code&gt; Grape API endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
With the Grape gem, building powerful API endpoints in Ruby on Rails becomes a breeze. In this blog post, we explored how to handle the User model and create an API endpoint at &lt;code&gt;api/v1/users&lt;/code&gt;. By following the steps outlined above, you can easily implement CRUD operations for managing users via the API. Grape's simplicity and flexibility make it an excellent choice for building robust APIs in Ruby on Rails.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>gem</category>
      <category>rails</category>
      <category>grape</category>
    </item>
    <item>
      <title>ChatGPT Alternative Built With Superpowers - ChatSonic ROR Gem</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Sat, 15 Apr 2023 18:14:26 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/chatgpt-alternative-built-with-superpowers-chatsonic-ror-gem-4fo3</link>
      <guid>https://dev.to/samalasumanth0262/chatgpt-alternative-built-with-superpowers-chatsonic-ror-gem-4fo3</guid>
      <description>&lt;p&gt;In today's fast-paced digital world, language generation has become a powerful tool for automating tasks, enhancing user experiences, and driving innovation in various industries. &lt;/p&gt;

&lt;p&gt;In this blog, we will dive into the world of "chatsonic" and explore how this &lt;a href="https://rubygems.org/gems/chatsonic" rel="noopener noreferrer"&gt;https://rubygems.org/gems/chatsonic&lt;/a&gt; Rails Gem can enable you to leverage the power of LLM ChatGPT in your Ruby on Rails applications. We will discuss the features, functionalities as well as provide examples and code snippets to demonstrate how it can be integrated into your Ruby on rails applications.&lt;/p&gt;

&lt;p&gt;On a high level ChatSonic Gem is a wrapper around the writesonic OpenAPI that can be easily integrated into your rails application by installing this &lt;a href="https://rubygems.org/gems/chatsonic" rel="noopener noreferrer"&gt;Gem&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Main Repository: &lt;a href="https://github.com/SamalaSumanth0262/chatsonic" rel="noopener noreferrer"&gt;https://github.com/SamalaSumanth0262/chatsonic&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 1: Installing Gem
&lt;/h3&gt;

&lt;p&gt;In your rails root directory, run this command &lt;code&gt;gem install chatsonic&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 2: Get the API Key
&lt;/h3&gt;

&lt;p&gt;Now head to &lt;a href="https://docs.writesonic.com/reference/finding-your-api-key" rel="noopener noreferrer"&gt;https://docs.writesonic.com/reference/finding-your-api-key&lt;/a&gt;, Create an account for first time users. please find the image below for reference&lt;/p&gt;

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

&lt;h3&gt;
  
  
  STEP 3: Initialising and Configuring the Gem
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;gem 'chatsonic', '~&amp;gt; 1.0', '&amp;gt;= 1.0.2'&lt;/code&gt; to GemFile or Simply run &lt;code&gt;gem install chatsonic&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now It's time to configure the gem with the help of API-KEY obtained from Step 1.&lt;/p&gt;

&lt;p&gt;Create a file &lt;code&gt;chatsonic.rb&lt;/code&gt; in initialisers folder which is right place to configure gem. Insert the below small chunk of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ChatSonic.configure do |config|
  config.access_token = "****" #required, Always fetch from ENV file, ENV["API-KEY"]
  config.uri_base: "https://api.writesonic.com/", # Optional, Used to override the default
  config.request_timeout: 240 # Optional, Used to override the default ( Just in case if the prompt take more 120 seconds)
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or You can directly initialise by creating a instance of the gem like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client = ChatSonic::Client.new # if you have already initialised
# OR
client = ChatSonic::Client.new(access_token: "Your API Key")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  STEP 4: Getting the Prompt
&lt;/h3&gt;

&lt;p&gt;Now from anywhere in your rails application by using below chunk of the code you can get the &lt;strong&gt;PROMPT&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;response = client.prompt(parameters: {
    enable_google_results: true,
    enable_memory: true,
    input_text: 'Hi'
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;enable_google_results:&lt;/strong&gt; Gives your responses based on the data backed by google.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;enable_memory&lt;/strong&gt;: Stores all the previous conversations&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input_text&lt;/strong&gt;: Your prompt.&lt;/p&gt;

&lt;p&gt;This will give prompt response "Hello! How may i assist you today ?"&lt;/p&gt;

&lt;p&gt;Hurray !!! Thats it. Now you have integrated this Gem into your Rails Application. &lt;/p&gt;

&lt;h4&gt;
  
  
  Main Use Cases of this:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Act like ChatGPT with steroids&lt;/li&gt;
&lt;li&gt;Conversational AI&lt;/li&gt;
&lt;li&gt;Translational&lt;/li&gt;
&lt;li&gt;Content Writer&lt;/li&gt;
&lt;li&gt;More use cases can be found &lt;a href="https://writesonic.com/blog/chatgpt-chrome-extension-use-cases/" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Proposed Future Developments:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Make this gem powerful and be compatible with all the features listed in this page: &lt;a href="https://docs.writesonic.com/reference/introduction" rel="noopener noreferrer"&gt;https://docs.writesonic.com/reference/introduction&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading !!! Feel free to comment any kind of suggestions for this blog. I am all ears. Cheers !!!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you for inspiring !! Cheers. CEO Of writesonic &lt;a class="mentioned-user" href="https://dev.to/samanyougarg"&gt;@samanyougarg&lt;/a&gt;&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>chatsonic</category>
      <category>llm</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Command Driven Design Pattern - ROR</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Thu, 30 Mar 2023 22:14:57 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/command-driven-design-pattern-ror-3m53</link>
      <guid>https://dev.to/samalasumanth0262/command-driven-design-pattern-ror-3m53</guid>
      <description>&lt;p&gt;In this blog we'll dive into one lesser-known design pattern  but highly efficient for large scaled applications which helps the code repository to keep organised and can be easily scaled up.&lt;/p&gt;

&lt;h4&gt;
  
  
  Design Pattern Name: Command Driven Pattern
&lt;/h4&gt;

&lt;p&gt;Usually the request from client goes to the controller which speaks to the model ( database ) and send back the view or JSON.&lt;/p&gt;

&lt;p&gt;But in this design pattern request from controller goes to a command, and a command can be having number of actions items to perform and send the response back.&lt;/p&gt;

&lt;p&gt;In layman terms take an example of constructing a shopping mall. the action items are: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Buy the plot.&lt;/li&gt;
&lt;li&gt;Setting up the base.&lt;/li&gt;
&lt;li&gt;Raising the walls.&lt;/li&gt;
&lt;li&gt;Elevators&lt;/li&gt;
&lt;li&gt;Painting&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;so all these five steps can we performed a separate file called as &lt;strong&gt;COMMAND&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Lets consider this scenario:&lt;/p&gt;

&lt;p&gt;Example: On User Sign up, consider these following actions are to be performed. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User must be authenticated. &lt;/li&gt;
&lt;li&gt;User must be sent a logged-in alert email. &lt;/li&gt;
&lt;li&gt;User should be awarded some points. &lt;/li&gt;
&lt;li&gt;User should receive push notification.&lt;/li&gt;
&lt;li&gt;Audit for all the above actions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's create a folder in &lt;code&gt;app/&lt;/code&gt; called core and file called &lt;code&gt;Command.rb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Core::Command
  include ActiveModel::Validations

  attr_accessor :token

  def initialize(attributes = {})
    attributes.each do |name, value|
      if methods.include? "#{name}=".to_sym
        method("#{name}=".to_sym).call(value)
      end
    end
  end

  # this method can be ovveridden in other classes
  def run
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in Lets create &lt;code&gt;CreateUserCommand.rb&lt;/code&gt; in core folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Core::CreateUserCommand &amp;lt; Core::Command
  attr_reader :user_params

  def initialize(params)
    super(params)
    @user_params = params
  end

  def run
    ActiveRecord::Base.transaction do
      authenticate_user
      mailer("Account Created")
      award_points
      send_push_notification
      mailer("User Logged In")
    end
    # can be written in JSON builder a seprate file
    return { name: "Samala Sumanth", git: "https://github.com/SamalaSumanth0262"}
  end

  def authenticate_user
    # can be separate command for user authentication
    puts "User Authenticated"
  end

  def mailer(message)
    # can be separate command for mailer
    puts message
  end

  def award_points
    # can be written in separate command for awarding points
    puts "User has been awarded 10 points"
  end

  def send_push_notification
    # User Notification Command
    puts "User has been sent push notification"
  end
end

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

&lt;/div&gt;



&lt;p&gt;And Finally your controller should look 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;class UsersController &amp;lt; ApplicationController
  # bypass csrf protection for all the requests made
  protect_from_forgery with: :null_session
  before_action :set_user, only: %i[ show edit update destroy ]
  # /users/
  def create
   render json: ::Core::CreateUserCommand.new(user_params).run
  end

  private
    # Only allow a list of trusted parameters through.
    def user_params
      params.fetch(:user, {})
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats It. with this approach we have moved most of the logic into command instead of having them in fatty models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Please feel free to comment and suggest any kind of improvement.
&lt;/h3&gt;

&lt;p&gt;This blog is also inspired by: &lt;a href="https://blog.slava.dev/command-driven-architecture-for-ruby-on-rails-35949a0b0558"&gt;https://blog.slava.dev/command-driven-architecture-for-ruby-on-rails-35949a0b0558&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  You can contact me from my portfolio: &lt;a href="https://sumanthsamala.netlify.app"&gt;https://sumanthsamala.netlify.app&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>designpatterns</category>
      <category>ror</category>
      <category>webdev</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Database Seeding and Relationships using LARAVEL</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Wed, 26 Oct 2022 14:18:36 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/database-seeding-and-relationships-using-laravel-5278</link>
      <guid>https://dev.to/samalasumanth0262/database-seeding-and-relationships-using-laravel-5278</guid>
      <description>&lt;p&gt;Hi Fellas, In this blog, we'll walk through&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to create a table ( Migration ) and Model&lt;/li&gt;
&lt;li&gt;Creating relationships between models ( Ex Library has_many Books ).&lt;/li&gt;
&lt;li&gt;Seeding the database using the faker() library.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PHP any version ( LTS is recommended )&lt;/li&gt;
&lt;li&gt;Mysql ( for Database )&lt;/li&gt;
&lt;li&gt;laravel&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's get started !!!! whoooooeeeeeeee!!!! 🚀🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 1️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's create a new laravel project using the &lt;code&gt;laravel new demo&lt;/code&gt; here demo is my project name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;STEP 2️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change your current directory to the project created using the above command, in my case, it is &lt;code&gt;cd demo&lt;/code&gt;. Ignore this line for professionals 😜&lt;/li&gt;
&lt;li&gt;Make sure you fill in the details in the .env file&lt;/li&gt;
&lt;li&gt;Create a database called demo by &lt;code&gt;create database demo;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=demo ( create a database in MySQL called demo )
DB_USERNAME=your_mysql_usernamae
DB_PASSWORD=your_mysql_password 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;let's create two models 1. Ĺibrary 2. Books
by &lt;code&gt;php artisan make:model Library -m&lt;/code&gt;, &lt;code&gt;php artisan make:model Book  -m&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;-m creates the migration file where we can include the details about columns of the tables library and books &lt;/li&gt;
&lt;li&gt;By executing the above commands laravel will create two files in the model and database directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database/migrations/2022_10_25_185618_create_books_table.php
database/migrations/2022_10_25_185530_create_libraries_table.php
app/Models/Book.php
app/Models/Library.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 3️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before running the migration command let's tell the laravel what are the columns that will be present in the model's created above &lt;/li&gt;
&lt;li&gt;Let's get our hands dirty by writing some code now.
Add the below code in the &lt;code&gt;public function up()&lt;/code&gt; method in the library and book the migration file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// code to be added to the library migration file 
 Schema::create('libraries', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;timestamps();
            $table-&amp;gt;string('name');
            $table-&amp;gt;string('librarian_name');
            $table-&amp;gt;datetime('opening_time');
            $table-&amp;gt;datetime('closing_time');
        });
// code to be added to the book migration file

 Schema::create('books', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;integer('library_id');
            $table-&amp;gt;timestamps();
            $table-&amp;gt;string('name');
            $table-&amp;gt;string('author_name');
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 4️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;let's create or migrate the columns into the database by running &lt;code&gt;php artisan migrate&lt;/code&gt;. You should see a log like this&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;strong&gt;STEP 5️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let us define the &lt;code&gt;has_many&lt;/code&gt; relationship in the models ( Ex: Library has many books )
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Library extends Model
{
    use HasFactory;

    public function books()
    {
        return $this-&amp;gt;hasMany(Book::class);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 6️⃣:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's create and load the database with some dummy data by using seeder files.&lt;/li&gt;
&lt;li&gt;Create a factory file using &lt;code&gt;php artisan make:factory BookFactory --model=Book&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a seeder file by &lt;code&gt;php artisan make:seeder BookSeeder&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code to BookFactory.php file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory&amp;lt;\App\Models\Book&amp;gt;
 */
class BookFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array&amp;lt;string, mixed&amp;gt;
     */
    public function definition()
    {
        return [
            'library_id' =&amp;gt; $this-&amp;gt;faker-&amp;gt;randomDigit(),
            'name' =&amp;gt; $this-&amp;gt;faker-&amp;gt;text(),
            'author_name' =&amp;gt; $this-&amp;gt;faker-&amp;gt;text(),
        ];
    }
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the following code to &lt;code&gt;BookSeeder.php&lt;/code&gt; to create 10 records in the Books table
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use \App\Models\Book;

class BookSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Book::factory(10)-&amp;gt;create();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally Run the seeding command &lt;code&gt;php artisan db:seed --class=BookSeeder&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly, we can write both Seeder and Factory files for the library model too. &lt;/p&gt;

&lt;p&gt;We can verify the data by running the select query from our database &lt;code&gt;select * from books&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Entire code is present in GitHub repo&lt;/strong&gt;: &lt;a href="https://github.com/SamalaSumanth0262/LARAVEL-Relationships-Seeding" rel="noopener noreferrer"&gt;https://github.com/SamalaSumanth0262/LARAVEL-Relationships-Seeding&lt;/a&gt;, Feel free to raise PR or contribute. we can add a hacktober-fest label too if required so that it counts towards the contribution&lt;/p&gt;

&lt;p&gt;For those who don't know hacktober fest, No worries I was one of them 😜 &lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;https://hacktoberfest.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please feel free to comment or any suggestions are welcome. Cheers !!!!!!!&lt;/p&gt;

&lt;p&gt;You can get in touch with me on&lt;br&gt;
Website🧑🏻‍💻: &lt;a href="https://sumanthsamala.netlify.app/" rel="noopener noreferrer"&gt;https://sumanthsamala.netlify.app/&lt;/a&gt;&lt;br&gt;
Linkedin🗒: &lt;a href="https://www.linkedin.com/in/samala-sumanth-82431161/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/samala-sumanth-82431161/&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/SamalaSumanth0262" rel="noopener noreferrer"&gt;https://github.com/SamalaSumanth0262&lt;/a&gt;&lt;br&gt;
twitter: &lt;a href="https://twitter.com/sumanth0262" rel="noopener noreferrer"&gt;https://twitter.com/sumanth0262&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>REST API's for CRUD Operation Using Spring Boot</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Wed, 03 Aug 2022 23:06:00 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/rest-apis-for-crud-operation-using-spring-boot-24in</link>
      <guid>https://dev.to/samalasumanth0262/rest-apis-for-crud-operation-using-spring-boot-24in</guid>
      <description>&lt;p&gt;In this article, Under 10 Steps we shall look at how to create a simple RESTful api with spring boot by taking an example of USER.&lt;/p&gt;

&lt;h4&gt;
  
  
  Required Pre-requisites 🗣:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Java installed on the machine 👨‍💻.&lt;/li&gt;
&lt;li&gt;Postman to test the API's.&lt;/li&gt;
&lt;li&gt;Willing to learn 😉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its time to jump into the code 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 1&lt;/strong&gt;: Create a base project from &lt;a href="https://start.spring.io/" rel="noopener noreferrer"&gt;https://start.spring.io/&lt;/a&gt;. Give a project name and description. Add the 3 required dependencies: &lt;strong&gt;Spring Web, Spring Data JPA and MySQL driver.&lt;/strong&gt;! Finally click on generate which will download a zip file. Extract and open in your preferred IDE like IntelliJ, eclipse or NetBeans.&lt;/p&gt;

&lt;p&gt;In my case the application name is &lt;strong&gt;crud&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;STEP 2&lt;/strong&gt;: Lets create some boilerplate by creating three folders in &lt;code&gt;crud/src/main/java/com/example/crud/CrudApplication.java&lt;/code&gt; which are 1. controller 2. model 3. repository 4. service. Typically your folder structure should look like below.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;STEP 3&lt;/strong&gt;: Create a Database and a &lt;code&gt;users&lt;/code&gt; table  with &lt;code&gt;user_id ( primary Key ), first_name and email&lt;/code&gt; in your mysql&lt;br&gt;
execut the following code which does the job for you in mysql terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE `user_schema`.`users` (
  `user_id` INT NOT NULL AUTO_INCREMENT,
  `first_name` VARCHAR(45) NULL,
  `email` VARCHAR(45) NULL,
  UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC),
  PRIMARY KEY (`user_id`));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add the following code in &lt;code&gt;crud/src/main/resources/application.properties&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spring.datasource.url = jdbc:mysql://127.0.0.1:3306/user_schema
#username and password of mysql 
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 4&lt;/strong&gt;: Let's do the magic by writing some code in these Folders. Create a file named &lt;code&gt;User.java&lt;/code&gt; in &lt;code&gt;model&lt;/code&gt; folder and add the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.crud.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "users")
public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="user_id")
    private Long id;

    @Column(name="first_name")
    private String firstName;

    @Column(name="email")
    private String email;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 5&lt;/strong&gt;: Now create another file in &lt;code&gt;repository&lt;/code&gt; package named &lt;code&gt;UserRepository.java&lt;/code&gt; where it's class is extended from &lt;code&gt;JPARepository&lt;/code&gt; to enable query execution abilities like &lt;code&gt;create()&lt;/code&gt;, &lt;code&gt;update()&lt;/code&gt;, &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;delete()&lt;/code&gt; methods. finally add the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.crud.repository;


import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.example.crud.model.User;

// @Repository tells the spring boot that it wrapped with User Table with sql execution queries.
@Repository
public interface UserRepository extends JpaRepository&amp;lt;User, Long&amp;gt; {
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 6&lt;/strong&gt;: Now Inside your &lt;code&gt;service&lt;/code&gt; folder create a file named &lt;code&gt;UserService.java&lt;/code&gt;. In this service layer we typically handle the business logic 🤖.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.crud.service;
import com.example.crud.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.crud.repository.UserRepository;
import java.util.List;

@Service
public class UserService {

    @Autowired
    UserRepository userRepository;

    public User createUser(User user){
        return userRepository.save(user);
    }

    public List&amp;lt;User&amp;gt; getUsers(){
        return userRepository.findAll();
    }

    public void deleteUser(Long userId){
        userRepository.deleteById(userId);
    }

    public User updateUser(Long userId, User userDetails){
        User user = userRepository.findById(userId).get();
        user.setFirstName(userDetails.getFirstName());
        user.setEmail(userDetails.getEmail());
        return userRepository.save(user);
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STEP 7&lt;/strong&gt;: Now inside the &lt;code&gt;controller&lt;/code&gt; folder, create a file named &lt;code&gt;UserController.java&lt;/code&gt;. This is the first and foremost layer when a request hits the server. This is right place to do validate the params or authorising the API or adding some middleware validations. But right now we only focus on writing the basic structure of the controller.&lt;br&gt;
Finally add the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.crud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.example.crud.model.User;
import com.example.crud.service.UserService;

// spring will understand that the methods in this class will follow rest convention
@RestController
@RequestMapping("/api")
public class UserController {
    // spring will create a bean when we do a autowiring
    @Autowired
    UserService userService;

    // invoking the spring-boot that this is end point /users
    // to create USER
    @RequestMapping(value="/users", method=RequestMethod.POST)
    public User createUser(@RequestBody User usr) {
        return userService.createUser(usr);
    }

    // to get all the list of Users
    @RequestMapping(value="/users", method=RequestMethod.GET)
    public List&amp;lt;User&amp;gt; readUsers() {
        return userService.getUsers();
    }

    // to update the values of USER
    @RequestMapping(value="/users/{userId}", method=RequestMethod.PUT)
    public User readUsers(@PathVariable(value = "userId") Long id, @RequestBody User empDetails) {
        return userService.updateUser(id, empDetails);
    }

    // to delete the record from the DB
    @RequestMapping(value="/users/{userId}", method=RequestMethod.DELETE)
    public void deleteUsers(@PathVariable(value = "userId") Long id) {
        userService.deleteUser(id);
    }

}

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

&lt;/div&gt;



&lt;p&gt;Finally your repository directory should look like:&lt;/p&gt;

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

&lt;p&gt;Hurray !!!!! Thats it !! 🤘🤘 Now you can start 🏎 the application on port number 8080 (of course the default port)&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; Test 👻 your API using postman&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg86ksg66za2mftzn70zf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg86ksg66za2mftzn70zf.png" alt="Post Man Create"&gt;&lt;/a&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsc78a8fjys5ffc2qwo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsc78a8fjys5ffc2qwo7.png" alt="Post Man get Users"&gt;&lt;/a&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkf7zy8yd4fl5t7kf7vy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkf7zy8yd4fl5t7kf7vy.png" alt="Post Man Update User"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please find the postman collection link here: &lt;strong&gt;&lt;a href="https://www.getpostman.com/collections/763c722809426a268aac" rel="noopener noreferrer"&gt;https://www.getpostman.com/collections/763c722809426a268aac&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PS: You can find the github repository here &lt;strong&gt;&lt;a href="https://github.com/SamalaSumanth0262/Spring-Boot-CRUD" rel="noopener noreferrer"&gt;https://github.com/SamalaSumanth0262/Spring-Boot-CRUD&lt;/a&gt;&lt;/strong&gt; . Do &lt;strong&gt;follow me on &lt;a href="https://github.com/SamalaSumanth0262" rel="noopener noreferrer"&gt;https://github.com/SamalaSumanth0262&lt;/a&gt;&lt;/strong&gt; 🙋‍♂️ or &lt;strong&gt;&lt;a href="https://twitter.com/sumanth0262" rel="noopener noreferrer"&gt;https://twitter.com/sumanth0262&lt;/a&gt;&lt;/strong&gt; 🙋‍♂️   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hey Peeps, This is my first blog 🎯 on JAVA with spring boot. Please do leave any kind of improvements or suggestions. More than happy to hear🙇‍♂️.. Cheers !!! 🍻🍻&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>crud</category>
      <category>api</category>
    </item>
    <item>
      <title>Raw SQL vs Rails Queries</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Mon, 07 Jun 2021 05:49:34 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/raw-sql-vs-rails-queries-14dd</link>
      <guid>https://dev.to/samalasumanth0262/raw-sql-vs-rails-queries-14dd</guid>
      <description>&lt;p&gt;The key difference is that &lt;strong&gt;ActiveRecord&lt;/strong&gt; lets you be more productive by using a &lt;strong&gt;higher-level abstraction&lt;/strong&gt; which lets you write &lt;strong&gt;less code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This abstraction comes at a cost and can lead to performance problems if you don't pay attention to the queries that ActiveRecord generates. &lt;strong&gt;N + 1&lt;/strong&gt; queries can be a major problem here.&lt;/p&gt;

&lt;p&gt;My Observation is if you don't know how to perform an operation with ActiveRecord it is often better to write a bit of SQL with a test backing it and go back and refactor later.&lt;/p&gt;

&lt;p&gt;Alright, Let's make our hands dirty.&lt;/p&gt;

&lt;p&gt;Here is the schema of our DB which comes handy in wrinting SQL queries as well as rails queries.&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%2Fuser-images.githubusercontent.com%2F40859181%2F120958657-ced37e00-c775-11eb-902c-75d9bde2b275.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%2Fuser-images.githubusercontent.com%2F40859181%2F120958657-ced37e00-c775-11eb-902c-75d9bde2b275.png" alt="Blog Schema"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: A simple inner join.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAW SQL:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;select * from customers inner join votes on votes.customer_id = customers.id &lt;br&gt;
where customers.active = 1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active Record:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Customer.joins(:votes).where(active: true)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Inner join with two tables&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;RAW SQL:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;select * from customers inner join posts on posts.customer_id = customers.id inner join comments on comments.post_id = posts.id where customers.active = 1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active Record:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Customer.joins(posts: :comments).where(customers: { active: true })&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Explanation: The amount of code written has been drastically reduced in case of active record.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 3: Inner join with three tables.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAW SQL:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;select * from customers cst inner join posts pst on pst.customer_id = cst.id inner join comments cmt on cmt.post_id = pst.id inner join  votes v on v.comment_id = cmt.id where cst.active = 1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active Record:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Customer.joins(posts: [comments: :votes]).where(customers: {active: true})&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;PS: if you want to get the schema or the rails code you can find the repository &lt;a href="https://github.com/SamalaSumanth0262/SQL_vs_Rails" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this read gives you little idea of where to use SQL and rails queries. Please feel free add your thoughts or suggestions :D&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>sql</category>
      <category>performance</category>
    </item>
    <item>
      <title>Docker Fundamentals</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Sun, 30 May 2021 12:48:58 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/docker-fundamentals-101-l80</link>
      <guid>https://dev.to/samalasumanth0262/docker-fundamentals-101-l80</guid>
      <description>

&lt;p&gt;since you landed here you definitely want to know what docker is?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We'll start off by telling the problem statement&lt;/strong&gt;: let's say we want to use create-react-app where the OS is not compatible of node to install &lt;code&gt;npm install -g create-react-app&lt;/code&gt; 😿 , you can achieve this by using Docker Image. Hurray!!!! Interesting. isn't it? 🤔&lt;/p&gt;

&lt;p&gt;WHAT is docker? simply you can think off like a Sea Port harbour docker 🚢 where we have containers to be exported into other places across the world and container contains the goods and materials. Similarly, our docker also has containers but here we call those goods and materials as an Image, just a technical term. so all the images need a place to store we call it Docker Hub. just like a GitHub is the place to store code as simple as that.&lt;/p&gt;

&lt;p&gt;Now, How does docker solve our problem, Though the OS doesn't support node what if the docker image provides you with all the dependencies to install create-react-app… WOW, that's a solid idea !!!!! 💡 so Image is independent of the OS. Moving forward I'll show how to create an image and push it to docker hub. Here is the architecture diagram of a docker&lt;/p&gt;

&lt;p&gt;Without any delay, let's go ahead create our first image and store it in docker hub.&lt;br&gt;
Install docker from &lt;a href="https://docs.docker.com/engine/install/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Create a folder called docker-sample. or fork the repo from &lt;a href="https://github.com/SamalaSumanth0262/Docker-example.git"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir docker-sample &amp;amp;&amp;amp; cd docker-sample &amp;amp;&amp;amp; mkdir public &amp;amp;&amp;amp; cd public &amp;amp;&amp;amp; vim index.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;and write some HTML code you can refer &lt;a href="https://github.com/SamalaSumanth0262/Docker-example/blob/master/public/index.html"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;now vim Dockerfile .&lt;/li&gt;
&lt;li&gt;let's start adding the code to the file. FROM node:alpine , this line will fork the base node repo where our application code gets run. By doing this step we've just got a copy of machine and does not contain any application code&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;COPY . /usr/src&lt;/code&gt; , we copy all the files from the current directory and paste in /usr/src where usr stands for a universal system resource.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;WORKDIR /usr/src&lt;/code&gt; , we tell the container that usr/src in the source of my application code.&lt;/li&gt;
&lt;li&gt;Add RUN npm install, this will install packages in &lt;code&gt;package.json&lt;/code&gt; and also we have in-built npm installed in node:alpine.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;CMD ['npm', 'run', 'start']&lt;/code&gt; , RUN is a block command where the execution blocks but here we want to run a command asynchronously so we use CMD.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;EXPOSE 80&lt;/code&gt; , we are telling docker once the image runs in the container we expose port number 80.
Finally, your Dockerfile should look like this.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now then we have copied the code and we set the working directory and all set except we are left with building the image, we run this command now &lt;code&gt;docker build . -t docker_id/name_of_the app&lt;/code&gt; in my case its &lt;code&gt;docker build . -t 14bee0262/docker-sample&lt;/code&gt; where docker_id is the user_id of docker hub.&lt;br&gt;
Before uploading to docker hub we need to really check in our local whether the container is running image or not? we can run the image by &lt;code&gt;docker run --restart always -d -p 80:80 14bee0262/docker-sample&lt;/code&gt; you should see the below image in your localhost …taaadaaa!!!! &lt;br&gt;
- restart =&amp;gt; whenever there's is an exception docker restarts the image.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;d is for telling the docker to restart the daemon.&lt;/li&gt;
&lt;li&gt;p is the port number binded_container_port:exposed_port 
Now you can push this image by docker push user_id/name_of_image in my case its docker push 14bee0262/docker-sample and my image is here. you can check in your docker hub dashboard. Now where ever you are in the world whatever the OS configuration is you can just pull the image and run it and your server is UP Cheeeeerrrss!!!! 🍹 🍹 😄 😄. Anyways  Documentation is available for much more information . PEACE !!!!!!!!
PS: Any Suggestions, Any comments are heartfully welcome.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Make up for Rails console</title>
      <dc:creator>Samala Sumanth</dc:creator>
      <pubDate>Sun, 09 Aug 2020 12:36:52 +0000</pubDate>
      <link>https://dev.to/samalasumanth0262/make-up-for-rails-console-1ch3</link>
      <guid>https://dev.to/samalasumanth0262/make-up-for-rails-console-1ch3</guid>
      <description>&lt;p&gt;Peeps!!!! i felt that i should have done this earlier... Being a ROR dev i really feel uncomfortable to examine this default rails console. A linter or formatter for this problem might be a solution. Now comes the magic..scroll bottom !!!!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LqnUV2Cz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/05ey19iut5irvgc24kz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LqnUV2Cz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/05ey19iut5irvgc24kz6.png" alt="Alt Text" width="800" height="471"&gt;&lt;/a&gt;&lt;br&gt;
                            &lt;strong&gt;##### BOOOM #####&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g35hn2hF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/7pxamxikqpqi6e7pgovj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g35hn2hF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/7pxamxikqpqi6e7pgovj.png" alt="Alt Text" width="375" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just follow these 3 steps and make the magic happen!!!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Just add awesome_print gem in development group in &lt;code&gt;Gemfile&lt;/code&gt; which is located in root path of your application.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;group :development do
   gem 'awesome_print'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add this code block in by doing &lt;code&gt;vim ~/.pryrc&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require "awesome_print"
AwesomePrint.pry!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and save it by &lt;code&gt;:wq!&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This file is called when our rails console starts. so no need of running &lt;code&gt;source ~./pryrc&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here you go.. just play around rails console now . PEACE&lt;br&gt;
For more details you can refer documentation &lt;code&gt;https://github.com/awesome-print/awesome_print&lt;/code&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>awesomeprint</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
