Optimistic vs. Pessimistic locking in Rails

While performing concurrent operations, a database must ensure data integrity. ACID compliant relational database ensures this data integrity through its locking mechanism. ACID = Atomicity, Consistency, Isolation, Durability Locks can be at the database, table, page, or row level. Here is a beginner's guide to database locking in PostgreSQL. In this article, let's see how Rails provides a mechanism for optimistic locking on ActiveRecord models. However, before we proceed, let us first understand the basics of optimistic and pessimistic locking. What is optimistic locking? Let's take an example of two admin users, Mohan and Ritesh, managing the product inventory in their

Gracefully integrate Reactjs with Ruby on Rails in SaaS Applications

This blog illustrates how we can easily setup a ruby on rails application with ReactJs as a front-end framework

Insights and Strategies for upgrading Ruby on Rails applications

For the past few months at Kiprosh, we've done versions upgrade of multiple mid to large scale Ruby on Rails applications. One of them was running Rails version 3.2.22. That's where we found out that, we need to make a lot of changes in our codebase to run our application on version 4.0. Hence, we thought to write this blog post to share our insights and recommended strategies for upgrading such mid to large Rails applications. upgrading Ruby on RailsRails guides provide us a brief information on how to upgrade the Rails app, but we need to

Build Rails like console in Nodejs

Recently, our organization planned to migrate an internal application web API to Nodejs web API. We have everything to work on node app, but we were lacking a console where we can run queries and examine results to implement them in our controller or vice-versa. fig 1. Nodejs consoleWhat we have in Ruby on Rails frameworkrails_app $ rails c irb(main):005:0> User.first User Load (0.7ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => #<User id: 1, email: "aravind@kiprosh.com"

How to store emoji characters in MySQL database of a Ruby on Rails application

Emoji has become an essential part of communication in our digital lives. Hence, as developers, our applications should provide first-class support to them. In this blog post, we will explore how to store Emoji's in MySQL database. In one of our internal Ruby on Rails web application using MySQL database, we were facing an issue whenever a user tried to insert an emoji in the text of an article. The "save" functionality in UI ran infinitely (ajax) and logs were reporting following errors: ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xF0\x9F\x98\x8A ...' for column 'content' at

How we automated our recruitment process using Zapier, Airtable & Trello

As a tech organisation, we always strive to find suitable talent for available positions, and then move them quickly through the application funnel, from sourcing to hiring. The goal is to onboard a potential candidate as fast as possible. In this endeavor, we decided to automate our recruitment processes so that the overall time to screen, interview and to release an offer is relatively faster. Background Interested candidates apply on our website through careers page. We have a referral program for our associates so it also resulted in wider interest. We also receive direct applications through email on careers@kiprosh.

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

Implement client side validation in Active admin

Recently, we have to build an Admin dashboard for an e-commerce application. This involves adding stores, items their photos and other data typically needed for managing the data from admin side for non technical people. Since, we are using rails framework so we had two options that are best suitable as per our need administrate and active admin. The former is very popular recently as it has several advantages over the latter. Unlike active admin you don't have to understand the DSL. It's very flexible and easily customisable. But administrate is still in pre-1.0 version and not very stable

Use Spring to run RSpec quicker

Use spring to run RSpec - with spring - bundle exec spring rspec spec/controllers/api/v1/ Finished in 47.14 seconds (files took 1.58 seconds to load) 72 examples, 0 failures without spring - bundle exec rspec spec/controllers/api/v1/ Finished in 48.84 seconds (files took 29.23 seconds to load) 72 examples, 0 failures One of the reasons for RSpec tests being slow is the initial application boot time. This happens every time you make changes in your code and takes few seconds every time. You can reduce that by using spring to run your

Similarities between Ember FactoryGuy and rails FactoryGirl

While working with any application, testing plays most important role. Data is main requirement for writing proper test cases. We need different kind of data to test complex features and here factories plays important role. Data factory is blueprint that allows us to create an object, or a collection of objects, with predefined set of values. Factories makes it easy for us to define different kind of data. In rails or ember we create model object to write test cases. In rails many of us use FactoryGirl to create such test data using factories. Same way ember has FactoryGuy. Ember's