Book Image

Implementing AppFog

Book Image

Implementing AppFog

Overview of this book

AppFog is the leading platform-as-a-service provider of PHP, Ruby, Node.js, and Java solutions. It is used by developers worldwide to deploy tens of thousands of applications. AppFog delivers a reliable, scalable, and fast platform for deploying applications in the cloud.This book is a hands-on guide that will walk you through creating and deploying applications to the cloud using AppFog, which will allow you to get your application deployed without the hassle of setting up servers.This book demonstrates how to use the AppFog service to build an application and have it running in the Cloud. It will walk you through the initial AppFog setup process and explain how to create your first application in minutes.You will also discover how to use services such as databases to make your applications more powerful. You will also learn how to create applications from scratch.You will find out everything you need to know to get an application running in the cloud for the first time.
Table of Contents (13 chapters)
Implementing AppFog
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Fixing the application for Ruby 1.8.7


If you're using Ruby 1.9.2 or later, you can run the application unchanged; you can skip this section. To check which version of Ruby you are using, you can type:

$ ruby -v

If you're using Ruby 1.8.7, you'll have to modify the program. The problem is the main application source file app.rb. Here's the program as AppFog provides it:

require 'sinatra'
set :protection, except: :ip_spoofing

get '/' do
  erb :index
end

There are two problems with this code. They are as follows:

  • In Ruby 1.8.7, you have to explicitly indicate that you're using Gems. This is not necessary in later versions.

  • The set line is a workaround for a bug in the AppFog software. This bug has long since been fixed, but the set command does no harm in later versions of Ruby. However, it is syntactically incorrect in Ruby 1.8.7 so you should remove that line.

Edit the source code so it looks like this:

require 'rubygems'
require 'sinatra'

get '/' do
  erb :index
end

Note

Obviously, inconsistencies...