O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rails and Sinatra

With translations properly stored, we can now write our Translator app using Sinatra. Sinatra is a domain-specific language (DSL) for quickly creating web applications in Ruby with minimal effort. The “Hello world” is just a few lines of code:

 
# myapp.rb
 
require ​'sinatra'
 
get ​'/'​ ​do
 
'Hello world!'
 
end

We won’t access the Sinatra application directly, but we’ll integrate it with our Rails app. This allows us to reuse all the structure we already have in the Rails ecosystem, such as tests, sessions, authentication, and so on. Before we develop our Sinatra application, let’s write an integration test once again using Capybara to make our tests more robust and readable. First, let’s define ActiveSupport::IntegrationCase ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required