Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Many people praise Sinatra's ability to create simple projects in a single file. This is great and all but what if I want to use Sinatra for slightly larger project?

I'm fairly new to Ruby as a whole but have already found a couple ways to create a Sinatra application with separate models files, partitioning different groups or URLs into individual files, etc... But is there any best practice for this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

The step to take is to partition the application into multiple parts at the file level. Instead of having all of the routes in one file, split them up into logically separated files with different functionality groups in different files, which are all then require'd back into the main Sinatra application/Rackup file.

Although this makes your file structure prettier, it does not implement any true compartmentalization or organization beyond superficial divisions. The solution to this that seems to have garnered the most popularity and acceptance is the Padrino framework, which runs on top of and expands upon the Sinatra core to add controllers (for compartmentalization) and a bunch of Django-like features (drop-in authentication, administration, etc.).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.