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 ...

Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.