W5D2 - Roll Your Own Rails
Rails Lite
Today we started writing our own miniature version of Rails. Rails does a lot of work for you when you write a web app. The best way to understand what it is doing is to write Rails yourself.
An Example Rails Method
For a simple example of demystifying Rails magic, let's look at (part of) "redirect_to." This is a way to show the user a new page. In rails, you can say redirect_to users_url and it does just that. It communicates to the browser using "HTTP", so in order to write this method we had to create the HTTP response ourselves. That means setting a response string with a url and a status of "302" to send back to the browser. The browser knows that the code 302 means "temporary redirect." The url we provide tells the browser what page to request from the server on the next request-response cycle.
















