Created
December 15, 2016 16:54
-
-
Save badosu/b515d9536a1c08f1e2846a082de1623b to your computer and use it in GitHub Desktop.
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
extend Controllers | |
plugin :flow | |
plugin :container | |
route do |r| | |
r.on("users") do | |
r.is do | |
r.get to: 'users#index' | |
end | |
r.on(:id) do |user_id| | |
r.is do | |
r.get to: 'users#show', call_with: [user_id] | |
end | |
end | |
end | |
end | |
register_controllers |
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
module Controllers | |
def register_controllers | |
register('users') { UsersController.new } | |
end | |
end | |
Dir["controllers/*.rb"].each { |file| require_relative file } |
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 UsersController | |
def index | |
"users#index" | |
end | |
def show(user_id) | |
if user_id == "666" | |
"NOT FOUND" | |
else | |
"user show ##{user_id}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment