Mount Cuba App in Rails 4
Create the "Hello World" Cuba Rack app.
# lib/cuba_app.rb
require 'cuba'
class CubaApp < Cuba; end
CubaApp.define do
on get do
on root do
res.write 'Saludos desde Cuba'
end
end
end
Mount the Cuba app at a defined location.
# config/routes.rb
Rails.application.routes.draw do
mount CubaApp, at: '/cuba'
end
Load Ruby files in the lib folder.
# config/initializers/lib.rb
Dir["#{Rails.root}/lib/*.rb"].each { |file| load file }
Start your Rails application and visit http://lvh.me:3000/cuba
For more information about Cuba, visit http://cuba.is or call your local travel agent.
Cite:
http://guides.rubyonrails.org/routing.html#routing-to-rack-applications
https://github.com/soveran/cuba#composition
Written by Stan Carver II
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#