Book Image

Learning Sinatra

By : Sudeep Agarwal, Manoj Sehrawat
Book Image

Learning Sinatra

By: Sudeep Agarwal, Manoj Sehrawat

Overview of this book

<p>Sinatra is a Ruby framework that is widely used in the Industry. You can use it to make a single-page web app or a large-scale one. With the increased online footprint, you can create and deploy your own application.</p> <p>Whether you are brand-new to online learning or a seasoned expert, this book will provide you with the skills you need to successfully create, customize, and deploy a Sinatra application. Starting from the beginning, this book will cover how to install Ruby and Sinatra, construct the back-end, design and customize the front-end layout, and utilize the innovative and user-friendly features of ORMs. By sequentially working through the steps in each chapter, you will quickly master Sinatra's features to create your own application.</p> <p>With ample screenshots and code that offers a play-by-play account of how to build an application, Learning Sinatra will ensure your success with this cutting-edge framework.</p>
Table of Contents (17 chapters)
Learning Sinatra
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

When to use an ORM


Using an ORM has a lot of benefits over using standard SQL directly. Let's discuss some of them:

  1. Quick development: One needs to create tables manually and manage them when using SQL directly. Using an ORM reduces all such overheads.

    We can define classes that correspond to the table structure and every time we restart the application, the database is updated.

  2. Handling errors and transactions: Instead of writing SQL statements to manage transactions and handle errors, we can write simple Ruby code to do the same.

  3. Independent of the DBMS: ORMs are independent of the DBMS used. We can use the exact same code to communicate with any of the DBMS. We will just need to specify it while defining the connection and everything else will be taken care of by the underlying library.

So, in our case, using an ORM will be a lot of help. We will be using Sequel to help us with our backend needs.

Use the following code to install sequel:

gem install sequel

This will install the sequel and...