duplication removed(DRY)
Merge pull request #13370 from abhishekjain16/refactor_rails

duplication removed(DRY)