This is a reconstruction of the basic functionality of Rails, in six phases, developed as a test-driven project.
Set up a simple server using the WEBrick module, along with rudimentary request/response functionality.
Lay the foundation of ControllerBase, which provides the functionality that ActionController::Base does in Rails:
the render
and redirect_to
controller methods.
Use Kernel#binding
to evaluate ERB code and update the render
method to handle HTML content.
Store session information using WEBrick::Cookie
objects and a Session
class.
Update controllers to store session information.
Parse query string and post body to extract params at any level of nesting using Regex.
Set up a Params
object to store the params as a controller instance variable.
Set up a Route
object that stores a URL pattern, an HTTP method, a controller class, and an action name.
Extract the route params from the URL using Regex.
Set up a Router
object to match a requested URL with a Route
object given a HTTP request.
Modify controllers to invoke the appropriate action when the Router
is run.
flash
andflash.now
- CSRF protection