New Book: Jump Start Sinatra

Some of you may have noticed that I haven’t written so much on RubySource lately. The reason for this is that all of my time has been taken up writing a brand new book all about Sinatra! A few months ago, the nice guys at SitePoint asked me to write something for their brand new ‘Jump Start’ series. I’d already had some ideas for a Sinatra book, so I was really excited to get the opportunity to put my ideas into print.

The book will be called ‘Jump Start Sinatra: Classy Web Development Made Simple’. Konstantin Haase, the maintainer of Sinatra has agreed to be the technical reviewer for the book and his help and feedback have been invaluable. I’ve almost finished the first draft and would like to share a little bit of what it’s all about with the readers of RubySource .

The book is aimed at anybody with an interest in web development and a reasonable understanding of HTML and CSS. As the title suggests, it uses Sinatra to make the process of building a web application as simple and classy as possible. You don’t need to be an expert in Ruby, but some experience of programming would be a definite advantage.

The basic idea is that you should be able to work through it over the course of a weekend and by the end have a reasonably good idea of how Sinatra works. The book explains how to build a modular, database driven site from start to finish in simple and easy to follow steps. You can already see the sample application up and running online.

Here’s how the book is currently shaping up at the moment:

  • The first chapter introduces Sinatra, goes through installation and some basic routes.
  • The second chapter deals with routes and views and introduces the Slim templating engine as well as using Sass for CSS pre-processing.
  • The third chapter introduces DataMapper to build a database backend. It goes through the basic CRUD operations as well as building a RESTful web interface for them.
  • The fourth chapter explains configuration and settings in Sintra as well as using sessions to create a simple authentication login sysyem. It also explains how to deploy the site on the Heroku platform.
  • The fifth chapter shows how to use helpers as well as external gems to add more functionality to the application. In particular it uses the Pony gem to send emails and Sinatra-Flash to provide feedback messages. It also explains how to make the simple authentication into a Sinatra extension.
  • The sixth chapter demonstrates how to use CoffeeScript and JQuery to add some JavaScript effects to the front end of the application as well using Ajax to improve the feel of the application.
  • The last chapter goes through how to make the application easier to maintain by using Sinatra’s class-based modular style rather than the classical style application.

I hope that lots of you who read this site will find the book and interesting and informative read.

The book is due to be published in January, but there’s still time to make any changes and additions. If you’d like to see something in the book or particularly want to know how to do something in Sinatra then let me know in the comments below and I’ll do my best to squeeze some more in before the final deadline hits.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • Alan

    Need a user to test it. I have no Sinatra experience at all. Interested?

  • Alan

    I meant to put a question mark. Need a user to test it? <—-there it is! What great grammar!

  • http://hron.me hron84

    Is there a way to subscribe somewhere to get a notification when this book is become available by public? Exciting thing, I would like to find a time to learn Sinatra for a long time ago…

  • Dennis

    Would love to know when this comes out! For simple APIs or Web Apps, I see no reason why you shouldn’t use Sinatra!

  • lanastasov

    Please, Do explain how to add comments like these,
    with Sinatra. Where do you keep the comments and How you keep track on them?

  • Steve Robillard

    I would add two topics to your list security and testing.

  • http://mofo.com pony

    you should use sequel instead of datamapper, datamapper development has stopped, their are working on version 2, I wouldn’t want to read book about a dying technology. also, I know slim is nice but IRB is more mainstream.

  • http://daz4126.com/ Darren Jones

    Thanks for all the comments and feedback everybody!

    @Alan – we’ve already got lots of people testing the code out, but I’d love to hear what you think of it when it’s out.

    @hron and @Dennis – the release date is tentatively pencilled in for the end of January 2013. I’m sure there will be lots of publicity on RubySource when it is published¬

    @lanastasov – The comments on this site don’t use Sinatra and comments are not covered in the book, but I cover something similar (using a database to store song lyrics) that I’m sure could be adapted to a simple commenting system.

    @Steve – Unfortunately I couldn’t get testing in there, but I’m hoping to put a follow up to the book on RubySource or as a free pdf download that goes over testing the sample application from the book. As far as security, it gets mentioned in all sections of the book, but only at a basic level as the book is only an introduction to Sinatra.

    @pony – I take your point about DataMapper, but version 2 is still not ready yet and I wouldn’t write version 1 off as a dying technology just yet. Besides the book does mention there are other ORM options and using Sinatra it is ridiculously easy to use a different one (that’s more the point of the book, that you can choose your own way to do things). I make no apologies for using Slim, it’s far superior to ERB (which is what I assume you meant rather than IRB).

    Thanks again everybody!

    DAZ

  • Glauco

    How to upload files using Sinatra would be a great feature!