Reviewed code snippets with Best practices

Hello Team, Last week, I got the chance to review the latest code commits from one of our projects. This was a helpful step for me to learn good things from it. Please suggest me, if there are any improvements needed. Replace instance variable with local variable in partial. or so that use local variable in partial instead of instance variable. Best practice to add semicolon ( ; ) at the end of every statement in js file. Best practice to write css (styles) only in css folder rather than inline css in view file. Best practice to Use spaces around operators, and

An interactive shell for git

[git-sh][1] (git shell) is an interactive shell for git and its new way to use Git. git-sh provides a dedicated shell just for our Git commands. Installing git-sh: $ sudo apt-get install git-sh Start a shell with git-sh: $ cd liquor $ git-sh master!liquor *> At its simplest, git-sh saves you from typing the word git over and over. We are familier with these type of git commands: $ git status $ git add -p $ git commit $ git push With git-sh this gets easier: $ git-sh master!liquor *> status master!liquor *> add -p master!liquor *> commit -m "message" master!

Better Errors in Rails

[better_errors][1] is a Rack middleware that replaces the default standard rails error page with a more useful one. The default Rails error page is also useful, but there is so much output that we don’t usually need and also there is a lot of other things we might need to see. The features of better_errors gem are awesome: Full stack trace Source code inspection for all stack frames (with highlighting) Local and instance variable inspection Live REPL (Read-Eval-Print Loop) on every stack frame In this local and instance variable inspection is so useful. We can immediately

Method / Process to export active record data to excel file, save xls file on S3 and provide download xls feature

In one of our web application, we had a specific requirement wherein the client wanted the data from the app into a specific xls format. Thus we needed to export data from our app in this custom format and save the xls file on S3. Our app will then show a link to "Download" in ActiveAdmin UI clicking which it will start downloading this xls file from S3 on clients local PC. We have broken down the process into numerous steps, hope this will be helpful. The process goes as follows: The data from the app is exported

Stamp gem for Human friendly date and time format

[Stamp Gem(Stamp Gem)][1] Stamp gem is the best gem for converting format of Dates and Times in Human friendly formats. Its very easy to use in our rails application. We can use this gem as: run: gem install stamp or inlude this line in gem file gem 'stamp' then run: bundle install. Example: Suppose, I have a date = 2014-01-15 18:19:07 +0530 then we can convert this date into humans friendly date format like date.stamp('1-Jan-2000') => '15-Jan-2014' date.stamp('1st Jan') => '15th Jan' date.stamp('Jan 1, 2000') => 'Jan 15, 2014' date.stamp(

Download or Export excel records from active admin

activeadmin-axlsx gem [activeadmin-axlsx][1] gem is very useful to download or export excel records from active admin. It provides "XLSX" links to download Active Admin resources. We can use this gem by include this line in gem file: gem 'activeadmin-axlsx' then run: bundle install Now all resources of active admin index page include a 'XLSX' link. There is some example to customize 'activeadmin-axlsx'. Remove unnecessary column: app/admin/orders.rb ActiveAdmin.register Order do config.xlsx_builder.delete_columns :created_at, :updated_at end Change the style of column header: app/admin/orders.rb ActiveAdmin.register Order do