1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
require 'rubygems'
require 'ramaze'
# A very simple little application, you can simply run it and
# point your browser to http://localhost:7000
#
# You can change the port by setting
# Ramaze.options.adapter.port = 80
# this most likely requires root-privileges though.
# This example shows following (requests to the mentioned base-url) :
# - simple text-output from the controller [ / ]
# - showing you what your request looked like [ /simple ]
# - joining two strings [ /join/string1/string2 ]
# - join arbitary strings [ /join_all/string1/string2/string3 ... ]
# - sum two numbers [ /sum/1/3 ]
# - show if you made a POST or GET request [ /post_or_get ]
# - How to map your controllers to urls [ /other ]
# - Also try out the error-page, just pass something odd ;)
class SimpleController < Ramaze::Controller
map '/'
def index
"simple"
end
def join(first, second)
[first, second].join
end
def join_all *strings
strings.join
end
def sum first, second
"#{first.to_i + second.to_i}"
end
def post_or_get
request.request_method
end
end
class OtherController < Ramaze::Controller
map '/other'
def index
"Hello, World from #{self.class.name}"
end
end
Ramaze.start
|