Created
August 8, 2011 15:37
-
-
Save timuruski/1131974 to your computer and use it in GitHub Desktop.
An example of using plain Ruby classes as Controllers with Sinatra. No magic or rocket science required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App < Sinatra::Base | |
| before "/hello" do | |
| @controller = HelloController.new | |
| end | |
| get "/hello" do | |
| @controller.index | |
| end | |
| end | |
| class HelloController | |
| def index | |
| "Hello, world." | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment