2

i am trying to create a rake basic app first in a directory i created helloworld.ru with code

class HelloRack def call(env) ["200",{"Content-Type" => "text/plain"}, "Hello World"] end end run HelloRack.new

i run it with rackup helloworld.ru its working fine after that i created three files Massive.rb in same directory with code

module Rack
  class Massive
    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, response= @app.call(env)
      [status, headers, "<div style="font-size:5.0em">#{response} - it's all small stuff</div>"]
    end
  end
end

and other file's name is SmallStuff.rb

class SmallStuff
  def call(env)
    ["200", {"Content-Type" => "text/html"}, "Don't Sweat The Small Stuff"]
  end
end

and one more file's name is config.ru with code

require 'rubygems'
require 'rack'

use Rack::Massive
run SmallStuff.new

when i run rackup config.ru its giving me error

/home/ritesh/rails/config.ru:4: uninitialized constant Rack::Massive (NameError)
    from /var/lib/gems/1.8/gems/rack-1.4.4/lib/rack/builder.rb:51:in `instance_eval'
    from /var/lib/gems/1.8/gems/rack-1.4.4/lib/rack/builder.rb:51:in `initialize'
    from /home/ritesh/rails/config.ru:0:in `new'
    from /home/ritesh/rails/config.ru:0

how to remove this error i am new to rake applications can any one please provide rake apps tutorial or helpful links!!

mathlearner
  • 7,509
  • 31
  • 126
  • 189

1 Answers1

1

It looks like you are just missing one or two requires. First rename your other files to massive.rb and small_stuff.rb (to follow Ruby conventions), then require them something like this:

require 'rubygems'
require 'rack'

require_relative './massive'
require_relative './small_stuff'

use Rack::Massive
run SmallStuff.new
Steve
  • 15,606
  • 3
  • 44
  • 39
  • instead of require_relative use require and it removes the error.require_relative is undefined func for ruby1.8 – mathlearner Jan 28 '13 at 17:59