Skip to main content

Posts

Showing posts from May, 2018

How to Track Page Impressions in Ruby on Rails?

Many times, we need to track the page views of any page such as profile page, shopping sites page in a Ruby on Rails applications, for which we can make use of Impressionist gem to track those page details easily. It is a lightweight plugin that logs impressions per action or manually per model. We can log impressions multiple times per request. And we can also attach it to a model. Below are the simple steps needed to follow to implement it: Step 1: Create a sample app using scaffold. Step 2: Add “gem ‘impressionist’” gem to the Gemfile and install it by running bundle install command. gem ‘impressionist’, git: ‘https://github.com/jordanhudgens/impressionist’ Step 3: Nowgenerate the impressions table migration by running the below commands: rails g impressionist rake db:migrate Step 4: Now we need to update our controller that we want to add the impression or page views counting system. So first we have add the following method in our controller with men

AngularJS Web Application Automation with Protractor Tool

The dynamics of web development have changed over the years. The HTML single page coding with CSS styling is an obsolete method now. One of the open source front end web application framework is the JavaScript based AngularJS, which has been in the industry for around 6 years now. What reason do we need Protractor Framework for? Protractor is a node.js program that is used to write end-to-end test. The tests are written in javascript to simulate user stories on a web browser. Protractor is effectively built upon webdriver so a lot of stuff we do on protractor will seem very similar. JavaScript is utilized as a part of all web applications. As the applications develop, JavaScript additionally increments in size and many-sided quality. In such case, it turns into a troublesome situation for Testers to test the web application for different situations. In some cases, it is hard to catch the web components in AngularJS applications utilizing JUnit or Selenium WebDriver.

GraphQL With Ruby

Now a day’s most of the web or mobile applications fetch data from server which is stored in a database. REST API provides an interface to stored data that require by the applications. GraphQL is a query language for REST API's not for server databases. It is database agnostic and effectively can be used in any context where an API is used. GraphQL provide platform for declarative data fetching where client need to specify what data needs from API in response. Instead of multiple endpoints that return fixed data structures, a GraphQL server only exposes a single endpoint and responds with precisely the data a client asked for. GraphQL minimizes the amount of data that needs to be transferred over the network and improves applications operating under these conditions. Introduction to GraphQL API on Ruby on Rails Start with adding gem in Gemfile gem ‘graphql’ Run command bundle install Run command rails generate graphql:install Above command will add gr

How to send email without using any server side language with the help of node.js?

What is node.js? Node.js is a server-side platform built-in JavaScript framework The steps to be followed : Step 1: Install node.js Step 2: Install npm (node package manager) Step 3: Install node mailer by running :   “ npm install nodemailer “ Step 4: Create a file called “package.json” in your project folder and write the following code : Step 5: Run “ npm install “ Step 6: Create a “Server.js” Step 7: Create a form on index.html page Step 8: Write js code form Submit button, this code will check the validation before sending mail. Include this file on index.html by using : “  http://js/node-mailer-contact.js   “ index.html form (view) : Step 9 : Create a method for SMTP ( Simple Mail Transfer Protocol ) in “Service.js” file through which email will be send: Step 10: Create a method for sending email in “Server.js” file: Step 11: Start the node js server on the terminal by running : “ node Server.js “ It will look like : After filling the for

Data Searchning in Ruby on Rails using SearchKick Gem

What is SearchKick Gem? Searchkick Gem is a Ruby on Rails gem that runs on top of Elasticsearch and makes it easy searches in a Rails-friendly fashion. Searchkick supports the complete Elasticsearch Search API, as by using it our search becomes more advanced. In addition, it allows you to add more features including analytics, auto suggestions, and personalized results. The steps are required: Add the gem “gem ‘searchkick’ “ . Then run the bundle install command. Then we will generate the complete model by using Scaffold generator rails g scaffold Article name:string description:text After running the above command it will generate all the necessary files then we will run the database migration command. rake db:migrate The controller code will be modified like that Def index Query=params[:q].presence || “*” @artivles=Article.search( query, page: params[:page}, per_page: 25 ) end The model code will be modified like that searchkick def search_data { t