Controllers are the front level classes that expose your app to the web. They pass information to the model, retrieve information from the model, and pass data to views, which contain the final output for users.
Controllers are called via URIs, i.e. example.com/foobar/baz
Segment #1 is the controller name
Segment #2 is the controller method to call
Controller Naming Conventions
Controllers live in the Picombo::Controllers namespace. They must be prefaced with these modules in the file
Controllers are placed in the /controllers directory
Controller filenames must be named the same as the class name: class Foobar would live in /controllers/foobar.rb
Controller filenames must be lowercase
Controller arguments are passed via URI segments after the second, i.e. example.com/foobar/baz/foo/bar
This would match the baz method of the foobar controller, and match the arg1 and arg2 method arguments
def baz(arg1, arg2)
The arguments must match the method exactly or a 404 exception will occur
module Picombo
module Controllers
class Foobar
def index
Picombo::Core.response('Hello World!')
end
end
end
end
This controller and method could be called via example.com/foobar/index
Autoloader for missing controller names
# File lib/core/core.rb, line 290
290: def Controllers.const_missing(name)
291: filename = name.to_s
292:
293: require 'controllers/'+filename.downcase.gsub(/_/, '/')
294:
295: raise LoadError if ! const_defined?(name)
296:
297: klass = const_get(name)
298: return klass if klass
299: raise LoadError
300: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.