Book Image

Rails 4 Application Development HOTSHOT

By : Saurabh Bhatia
Book Image

Rails 4 Application Development HOTSHOT

By: Saurabh Bhatia

Overview of this book

<p>Rails is a rapidly moving, open source, web development framework, and keeping up to speed with it is a big task. You might have already built applications using it, but there have been significant changes in the syntax and semantic of the Rails framework in the latest upgrade.</p> <p>Rails 4 Application Development Hotshot shows you how to build the most popular types of applications using Rails 4, and highlights new ways to do things. The book also closely follows lots of the best practices, gems, and popular solutions already known to the community, and tracks the changes in these. This book brings new ideas to refactor and restructure code to make it perform better in production, and enables you to write production-ready code.</p>
Table of Contents (17 chapters)
Rails 4 Application Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a line graph of the daily click activity


For content creators, "clicks per day" is a very important metric. They love to see the interaction and engagement happening on a day-to-day basis. We can plot the click data for the authors of the articles using the morris.js charts where morris.js is a library for plotting the data as line charts, bar charts, and donut charts. This is the reporting part of our analytics dashboard.

Engage thrusters

We will now plot the data that we have collected and analyzed in our previous tasks:

  1. The morris.js library comes packaged as a gem. It also depends on an SVG that renders a canvas library called raphael js.

    Gemfile 
    gem 'morrisjs-rails'
    gem 'raphael-rails'
  2. We will add this to the Gemfile and run bundle.

  3. We will then define the JavaScript in our application.js file. We have to ensure that these lines are placed before require turbolinks and require_tree:

    app/assets/javascripts/application.js
    //= require raphael
    //= require morris
    //= require turbolinks...