Last active
December 18, 2015 00:49
-
-
Save soveran/5699081 to your computer and use it in GitHub Desktop.
Basic structure for a Cuba application.
This file contains 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
require "cuba" | |
# Here you can add helpers, models, filters, services, etc. | |
Dir["./routes/**/*.rb"].each { |rb| require rb } | |
Cuba.use Rack::MethodOverride | |
Cuba.use Rack::Session::Cookie, | |
key: "_app_name_", | |
secret: "_app_secret_" | |
Cuba.use Rack::Protection | |
Cuba.use Rack::Protection::RemoteReferrer | |
Cuba.define do | |
# Everyone can see these pages (users, admins and guests). | |
on "(about|contact-us)" do |page| | |
res.write "You have reached %s" % page | |
end | |
# Only logged in users are allowed inside this block. | |
on authenticated(User) do | |
run Users | |
end | |
# Only logged in admins are allowed inside this block. | |
on authenticated(Admin) do | |
run Admins | |
end | |
# Routes for guests handle the signup and login processes. | |
on default do | |
run Guests | |
end | |
end | |
run Cuba |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment