Recent posts

  • 5 Must have gems in Ruby on Rails development environment.

    I have been developing rails applications since 2014. I started my career with rails and since then I have worked on numerous rails projects.

    These are a few gems that I like to add to almost all of my projects (including the personal projects). These gems definitely increase productivity and make the developer’s life easier.

    These are my top 5 gems you should have in your development environment.

    read more
    ruby rubygems
  • A step by step guide to upgrade rails 4 application to rails 5

    Upgrading an application can be tedious if you don’t have good test coverage.

    This article covers the common issues you might face while upgrading the from rails 4 to 5.

    If you are upgrading to ruby 2.7 export RUBYOPT="-W0" to avoid getting your screen filled up with deprecations warnings

    export RUBYOPT="-W0"
    bundle exec rspec
    # OR use
    RUBYOPT="-W0" bundle exec rspec
    read more
    rails rails-upgrade
  • Elasticsearch::Model - Partial update with custom callbacks

    If you want to partially update the documents on Elasticsearch you can include Elasticsearch::Model::Callbacks module.

    You can also perform partial update with custom callbacks instead of indexing the whole document.

    Elasticsearch Version - 5.3

    Partially update a document

    There is update_document_attributes method in Elasticsearch::Model which is used for partial update but it’s not documented. You can still use the method to perform the partial update.

    read more
    ruby elasticsearch
  • Rails and TimeZone issue with query

    You must have faced timezone issue if you work with the application in different timezone. ActiveRecord does take care of the timezone while creating, updating or querying the records. The DateTime is converted to UTC before the query is executed.

    You will face issue if you are using raw queries or passing String instead of DateTime.

    read more
  • Elasticsearch::Model - Put Mapping

    The PUT mapping API allows you to add fields to an existing index. This method is available with Elasticsearch::Model but it’s not documented.

    Elasticsearch Version - 5.3

    Create a User model

    > rails g model user first_name:string last_name:string email:string phone_number:string
    invoke  active_record
      create    db/migrate/20180420162454_create_users.rb
      create    app/models/user.rb
    > rake db:migrate
    read more
    ruby elasticsearch
  • Generating migrations with proper commands

    Creating a table

    If the migration name is of the form “CreateXXX” and is followed by a list of column names and types then a migration creating the table XXX with the columns listed will be generated.

    $ rails g migration CreateUsers email:string:index


    class CreateUsers < ActiveRecord::Migration
      def change
        create_table :users do |t|
          t.string :email
        add_index :users, :email
    read more
    ruby rails
  • Include scoped associations

    Rails provide different ways to load associations from the database to avoid N + 1 query being fired. In this post, I will show you how to include associations with scope applied on them.

    I have two models User and Post with following associations:

    # app/models/user.rb
    class User < ActiveRecord::Base
      has_many :posts, dependent: :destroy
    # app/models/post.rb
    class Post < ActiveRecord::Base
      belongs_to :user
      scope :published, -> { where(published: true) }
    read more
    ruby rails
Recent Tweets
@deepakmahakale · Jun 12, 20

If you stash changes time to time this is for you:
instead of:
𝚐𝚒𝚝 𝚜𝚝𝚊𝚜𝚑
𝚐𝚒𝚝 𝚜𝚝𝚊𝚜𝚑 𝚜𝚊𝚟𝚎 <𝚖𝚎𝚜𝚜𝚊𝚐𝚎>
@deepakmahakale · May 27, 20

Switching the tabs just to check the PR status
$ gh pr status
👉🏻Pull request from the current branch
👉🏻Pull reque…
@deepakmahakale · May 27, 20

A new favorite tool on my system 💻👨🏻‍💻 💯
@deepakmahakale · May 09, 20

Check out this Meetup: May online meetup #Meetup via @Meetup