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 such as these between Ruby on your local system and Ruby on the AppFog infrastructures are unacceptable for serious application development. Since this book is using only Ruby to illustrate the development cycle, we don't deal with this issue. See Appendix A for more information.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.41.205