Use syntax_fix gem to change old ruby hash style

Change old Ruby 1.8 hash syntax to new one in Rails app. syntax_fix gem changes the hash style from ':key => "value"' to 'key: "value"' Put this line in your Gemfile: gem 'syntax_fix' syntax_fix This command will check and rewrite all files with the new syntax. options: v <-- be verbose about the actions p [PATH] <-- specify the relative path to start actions from Reference: https://github.com/HeeL/syntax_fix

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

send email attachments via postmark-api

Previously, I have added post on send email from application via postmark. [Check Here..][1] Now will see how to send attachment with email. In rails, action-mailer provides an easy way to add attachment file as attachments['filename.jpg'] = File.read('/path/to/filename.jpg') Links: [rails-guide-on-attchments(send attachments with email)][2] , [rails-attachments][3] Sending attachments via Postmark-api require "open-uri" def send_refer_pt_request(params, attachment) # attachment -> url of file saved on S3 if attachment.present? mime_type = MIME::Types.type_for(attachment).first url_data = open(attachment).read() attachments["#{attachment.split('/').last}"] = { mime_type:

public_activity gem

public_activity is the best gem for easy activity tracking of models and easy to integrate in your rails application. links: Github-doc, Demo STEPS: In your gemfile: gem 'public_activity' Generate migration for activities and migrate the database (in your Rails project): rails g public_activity:migration rake db:migrate Include PublicActivity::Model and add tracked to the model you want to keep track of: class Answer now, by default create/update/destroy activities are recorded in activities table.(basic CRUD actions) Displaying activities: (see more details) controller: def index @activities = PublicActivity::Activity.all end views: public_activity looks for

Cheat Gem to Get Cheats.

This gem is not something that you are going to use in project, However, This will help you to get all the cheatsheats, that will help us in getting up to speed. Setting up cheat gem gem install cheat The first command u need to try out is the sheets cheat cheat : How to use cheat gem cheat sheets : Show list of available lists in console. This will give u a list of available sheets like: git, cucumber, rspec, svn, ssh, loose_weight etc. The list is also growing continuesly How to use this, cheat git cheat cucumber If you

Send email from application via postmark

Postmark is widely used email delivery service for the web application. The “Postmark-Rails” Gem is a drop-in plug-in for ActionMailer to send emails via Postmark. Links: Postmark-app(Postmark-app) , Postmark-rails gem(Github Doc) , Postmark Developer’s Blog(Postmak Blog) To integrate it with your application: Create an account on postmark.com (it also provides free account), set your-email as sender’s signature. This email-signature only you can use to send email, by setting it in from address. In you environment files: (staging/ production) POSTMARK_API_KEY = your_postmark_api_key config.action_mailer.delivery_method = :postmark config.action_mailer.postmark_settings