Generating PDF files from HTML content

Although nowadays we have Email, SMS services integrated in most of web applications, sometimes there could be need of documentation for future reference which users may want to reuse later based on their need. Similar requirement we had in one of our web application where we wanted to provide option to user to generate single or bulk PDF files out of any HTML templates they have in their account. There was different features around the generation of PDF document but major work was involved in generation of PDF out of HTML which is also not difficult task when we have

Distributed indexing and searching with Apache SolrCloud

Since quite some time, we use Apache Solr in one of our project for indexing data to search it faster from Solr server instead of always searching it from main database and creating bottleneck. We use Sunspot gem which is ruby library for rails application to implement Apache solr. Recently we thought to implement Apache SolrCloud architecture in same application to manage our daily growing Solr data more efficiently with this powerful feature of Apache Solr. In brief, you can consider it as a another database where your data is indexed and stored as xml documents. You can query this

Hubspot CRM - how, what and benefits

Recently while working on one of our project we came across requirement where we wanted Hubspot integration with our application for ease of sales team to manage user's data and understand their interactions and trends in application. I will quickly explain few things about Hubspot here in my article. What is Hubspot? In brief, Hubspot is a CRM which helps you monitor and fine tune many things regarding your application. Based on my analysis I will shortly list down few most important of them in order to give you more insights about it - Closely monitoring user interactions with your

Setting up Sidekiq with Redis for background job processing

Before starting with setup process lets first briefly go through what Sidekiq is? and how it works? Sidekiq provides very handy and efficient way to perform most of our work asynchronously in a job. Provided Redis cache connection to it, it serializes all job parameters in Redis and deserializes it while picking it up for execution based on priority of job as it uses queue data structure to store each job in particular queue specified in job and each queue has its priority defined as high, medium, low etc. To setup Sidekiq with Redis in your application you can follow

Communicating with Sendgrid V3 API

Sendgrid provides email service which we can use for sending emails from our app and we can even track every details of any email sent through our Sendgrid account like whether it is delivered, opened, dropped and details of unsubscribed email addresses etc. There are also API endpoints provided by Sendgrid to access user subscribe/unsubscribe related data and email event data with respect to emails sent through your sendgrid account for which documentation link is provided at bottom. To understand this lets go through simple example to fetch sendgrid subscription groups data from your sendgrid account - Generate API

Sidekiq background job enqueued in after_save callback fails to access persisted record

Recently while working on one of our project, there was a requirement of scheduling background job for processing some stuff once record is saved. So I written enqueue logic for job in after_save callback of record. But then job started giving unexpected results. After long time of debugging I found that job was not able to fetch record from db which was just saved and after some researching on it I got to know that sometimes job scheduled in after_save callback fails to access that record as it tries to process it before transaction actually completes, so if

Automatic counter-cache issue with has-many association in Rails 4.2.x

Recently while working on one of our project there was an requirement of tracking count of records associated with has-many association. But also there was "is_hidden" flag set on some of the records which I do not suppose to count in counter as those were hidden records. So default counter_cache option of rails active-record was not appropriate in this case which automatically counts and caches the number of associated records and keeps cache updated. Refer following model code for this. class Order < ActiveRecord::Base belongs_to :customer, counter_cache: true end class Customer < ActiveRecord:

Delayed job object serialization and deserialization issue

Recently in one of our project there was a requirement to send SMS notification to users and task was to perform this functionality as background job using delayed job service. I wrote following code for sending SMS notifications to user and it was working fine. Then I just did one liner change in my code to process send_sms method asynchronously using handle_asynchronously method of delayed job and thought it will work as expected. attr_reader :client, :sender, :recepient, :message def initialize(recipient_ph_number, message_details) @client = ACCOUNT_SID, AUTH_TOKEN @sender = TWILIO_PHONE_

Using Stripe API for Payment Transactions and generating Sales Report

Recently we had requirement to generate weekly sales report in one of the E-commerce apAs we were using Stripe services for payment handling, I studied some of Stripe API methods and how it actually works. So in this article I will briefly explain how we can handle payment through Stripe and how we can get sales data from Stripe. Firstly these are few basic steps to start using Stripe API: Add 'stripe' gem to your gemfile. bundle it You will get secret and public key pairs for live and test mode each from your Stripe account. You need to set

Integrating jquery-tokeninput plugin for getting tokenized input in text-field

Recently while working on one of our app there was a scenario where I was expecting text-field input as multiple values from predefined list of values in database. Also, user should get suggestion for matching values from database as he types in that text-field and value which do not exist in database should not be allowed to enter. I found one perfect solution on this scenario, that is [jquery-tokeninput][1] What I did to integrate plugin is very simple and as follows- Add jquery.tokeninput.js to your javascripts folder. Add token-input-facebook.css or token-input.css (You can add any