Skip to content

Instantly share code, notes, and snippets.

@soveran
Last active December 18, 2015 00:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soveran/5699081 to your computer and use it in GitHub Desktop.
Save soveran/5699081 to your computer and use it in GitHub Desktop.
Basic structure for a Cuba application.
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