Академический Документы
Профессиональный Документы
Культура Документы
generator
July 23, 2013
Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort. - sinatra
readme
The only downside is that it doesnt offer you the typical MVC like Rails.
Lot of times Rails is an overkill for a simple application and Sinatra seems like a perfect choice.
Since using Sinatra, you could write all your code in a single file, and at one time it becomes
really hard to manage the code and you may feel the need of porting it to a framework like Rails.
However, you dont need all the features that comes with Rails. What you need here is some
kind of modularization in your application. For this very purpose I created a gem called
modularize_sinatra
.
|-- Gemfile
|-- Rakefile
|-- config
| `-- environment.rb
|-- config.ru
|-- lib
| |-- app.rb
| |-- controllers
| | `-- user.rb
| `-- views
| `-- users
| `-- index.erb
|-- myapp.rb
|-- public
|-- script
|-- spec
| |-- controllers
| | `-- user_spec.rb
| |-- spec_helper.rb
| `-- support
`-- tmp
Note the lib/models in above point. You could create a directory called models in lib directory
to place your models and it will also be loaded.