Rails 4 Application Development HOTSHOT (2014)

Preface

In the past few years, Rails has emerged as one of the most popular choices of framework for developing web applications. It is also one of the most popular courses on all the major websites that teach web development, and a lot of developers have built a career out of it. Rails is known for providing productivity to developers and allows them to write clean and functional human-readable code. The latest major version of Rails, Rails 4, is a feature-packed update with a lot of new syntaxes and patterns.

Rails 4 Application Development Hotshot presents a practical approach to upgrade your Rails knowledge to Rails 4. This is done by building the most popular types of applications that people usually build using Rails and highlighting the new ways of doing this as opposed to the old ones in the latest version. The book also closely follows best practices and the commonly used gems and their compatibility with the latest Rails version. While working on these projects, we will also see some new design patterns and get ideas to refactor our current codebase. This book will help you write basic applications that are customizable and scalable and introduce you to a wide spectrum of concepts and ideas.

What this book covers

Project 1A Social Recipe-sharing Website, explains how to create a website where many users can sign up, log in, create food recipes, and categorize them into different types.

Project 2Conference and Event RSVP Management, explains how to create an application where users can create events, organize meetups for different topics and themes, and other users can join them in these events.

Project 3Creating an Online Social Pinboard, covers how to create an online pinboard, where a user can pin whatever he/she likes on to it and organize these objects. These pins can be repinned by other users on to their pinboards and thus create an online collection of the things or objects that people like.

Project 4Creating a Restaurant Menu Builder, covers how to build a fully responsive system to create and manage menus for a restaurant. This project will port restaurant menus to tablets and smartphones and also demonstrate how to make an SaaS application in Rails.

Project 5Building a Customizable Content Management System, explains how to create a customizable content management system to power simple content-driven websites. We will effectively create a system where designers will have the freedom to choose the frontend they want and end users can easily manage the content for that frontend.

Project 6Creating an Analytics Dashboard using Rails and Mongoid, will cover tracking clicks, page views, and the location of the visitors who read the content generated from the website. We will analyze the data and generate different types of graphs that represent different types of data.

Project 7Creating an API Mashup – Twitter and Google Maps, will dive into an API mashup of Twitter and Google Maps that will generate an application to map the locations of your friends who are tweeting. We will also filter these people based on country names.

Project 8API Only Application – Backend for a Mobile App, explains an application where the entire backend is in the form of an API. The entire data will be available on the frontend in the form of JSON through API endpoints. The frontend can be a web or mobile application.

Project 9Video Streaming Website using Rails and HTML5, explains how to create an application to upload and encode videos. This application will allow visitors to stream and watch videos using an HTML5-based player.

Project 10A Rails Engines-based E-Commerce Platform, explains how to create a Rails engine for generating an e-commerce application. This is mountable inside a blank Rails application.

What you need for this book

In order to work with the projects in this book, you will need the following installed on your system:

·        Ruby 1.9.3

·        Rails 4

·        MySQL 5+

·        MongoDB

·        jQuery

·        ImageMagick

·        RMagick

·        Git

·        Morris.js

·        Apache Solr

·        Apache Tomcat

·        Bootstrap

·        Sass

·        Sublime Text

·        A tool for mock-ups

·        Haml

·        Memcached

·        Twitter API keys

·        Google Maps API keys

·        The Rails API

·        FFmpeg

·        Redis

·        Video.js

·        A GitHub account

·        Devise

·        Doorkeeper

All projects have been upgraded and tested with Ruby 2.0 and Rails 4.1.0 beta.

Who this book is for

This book is aimed at developers who are already familiar with the basics of the Rails framework and have worked with Rails 3.2 or earlier versions. As the book follows a practical approach and uses terminology specific to Rails and web programming, it is assumed you have some prior experience with the development of applications. This book will help you upgrade your knowledge and improve its applicability.

Conventions

In this book, you will find several headings that appear frequently. To give clear instructions of how to complete a procedure or task, we use:

Mission briefing

This section explains what you will build, with a screenshot of the completed project.

Why is it awesome?

This section explains why the project is cool, unique, exciting, and interesting. It describes what advantage the project will give you.

Your Hotshot objectives

This section explains the eight major tasks required to complete your project:

·        Task 1

·        Task 2

·        Task 3

·        Task 4

·        Task 5

·        Task 6

·        Task 7

·        Task 8

Mission checklist

This section explains any prerequisites for the project, such as resources or libraries that need to be downloaded, and so on.

Task 1

This section explains the task that you will perform.

Prepare for lift off

This section explains any preliminary work that you may need to do before beginning work on the task.

Engage thrusters

This section lists the steps required in order to complete the task.

Objective complete - mini debriefing

This section explains how the steps performed in the previous section allow us to complete the task. This section is mandatory.

Classified intel

This section provides extra information that is relevant to the task.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "In case the form validation fails, the file field is reset."

In all code blocks, the first line is the name of the file kept there for your reference, followed by the code. An example of a code block is shown as follows:

app/models/event.rb

class Event < ActiveRecord::Base

  belongs_to :organizers, class_name: "User"

end

Database migrations that appear in the book appear without the filename as the generated filename varies from system to system. Following is how it is defined in the book:

class AddPlanIdToUsers < ActiveRecord::Migration

  def change

    add_column :users, :plan_id, :integer

  end

end

Any command-line input or output is written as follows:

:~/pinpost$ rails g jquery:install

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "We are going to select From Scratch and build our wireframes using the given set of tools."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.