Sometimes we come across situations where we need to count numbers of words, characters etc. from some content. Lets say we are creating a Rails app like http://www.ghostbloggers.net/ in which the user buy/sell their content, there users are charged based on the number of words written in the article. This can easily be achieved by the words counted gem which gives you the count of the number of words, characters, longest word etc. from the content passed as an input.

If we want to use it in our Rails app then we just need to add it to our gemfile.


RuboCop is a very popular gem among ruby developers for the static code analysis of the ruby codebase. It does static code analysis as per ruby style guide. If you are a beginner in Ruby and Rails, it is highly recommended to use this gem as it will help you a lot to improve your coding skills.

The first thing you need to do is installing the rubocop gem.

$ gem install rubocop

You can always fire rubocop shell command from base directory of your source code to start code analysis but how about your favourite text editors help you…


Sometimes we come across situations where we need to add tags to some items e.g. there is an online shopping website which sells various items such as clothes, electronics, books, mobile accessories .etc. Now if there are items such as earphones, power banks, data cables etc. these all can be commonly tagged as mobile accessories. Tagging makes it easy to group the items and also facilitates searching. So when any user searches for the mobile accessories we can show all the items related to this tag.

jQuery tag-it is an excellent jQuery UI plugin with auto-complete support. …


Credit https://unsplash.com

Sails is a lightweight framework that sits on top of Express. Its ensemble of small modules work together to provide simplicity, maintainability, and structural conventions to NodeJS apps.

What is SailsJS?

Sails is one of the most popular MVC framework used to build NodeJS apps. And for those who are from Ruby on Rails background will find SailsJS easy to use because of the directory structure is similar as any Rails app. Sails can be used to create Rest API’s, chat application, multiplayer games. etc. and many more. Just like Rails, it help to reduce boilerplate code.

Features

  • 100% Javascript
  • Compatible with MySQL, MongoDB…


While working on the project we came across the situation where the client told us the page load time of our home page is very high and we must do anything in the world in order to reduce this load time as it is the heart of our website.

As a result, we moved to some open sources tools to analyze our web page Google Page Speed, GT Metrix, Web Page Test to name a few.

Then we found the culprit! They were the high quality images (which were apple of our clients eye) on the page. And it contributed…


Credit: Piexa

In my previous post I explained what is Handlebars JS and how we can use it with Ruby on Rails. In this article lets look at some of the useful helpers provided out of the box by Handlebars, how we can add custom helpers and also how we can create reusable partials.


Mailchimp and webhooks

This article will guide you on how we can take the advantage of the Mailchimp web hooks in order to keep our database synchronized with mailchimp data. Actually in our database we stored the data from mailchimp user profile such as email, name and subscription status(i.e subscribed or unsubscribed).

Now to keep our database column updated there are two ways:

  1. Fire an mailchimp API call whenever the user signs in or update data once in day. But its way too costly. What if the profile data of the user updates occasionally ?
  2. Take advantage of the mailchimp web hooks which…

Rails + Mocha JS + Chai JS

It has been quite some time since we started writing RSpecs for our Rails applications. We had written tests for our rails models, views and controllers. So whole MVC part was covered with tests. In the beginning we had very less JavaScript code in our applications but with the time passing by our app’s Javascript code increased exponentially. With more than 1000 Javascript functions, we started to feel we need tests for this since we cannot test all this manually.

After digging many links and resources we found following popular Javascript testing frameworks which works with our rails app.

  1. Konacha

PC: www.pexels.com

Requirement: Compare two contents(HTML, JavaScript code or any other text) and find text difference in percentage(%) between them.

Technology: Ruby on Rails

Versions: Rails: 5.1.4 , Ruby: 2.4.1 (would work with almost any version)

Git Repo: https://github.com/AnkurVyas-BTC/compare

We are going to build something like below.


React + Rails + Webpacker

This tutorial will guide you on how to create a Ruby on Rails application and add the power of webpacker and React JS to it.

Let’s have a brief introduction to Webpacker and React JS. If you are familiar with React JS and Webpacker directly go to Implementation section.

What is React JS?

  • React JS is a JavaScript library for building user interfaces and is developed by Facebook.
  • React allows developers to create large web-applications that use data and can change over time without reloading the page.
  • It aims primarily to provide speed, simplicity and scalability. React processes only user interfaces in applications.
  • It…

Ankur Vyas

Ruby On Rails Developer, JavaScript Lead, Quick Learner, Reader, Writer, Always in Mood !!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store