Sinatra frame MVC pattern

I want to start coding with the Sinatra framework, but I cannot find the MVC pattern for this structure. Is the template or framework "MVC-Sinatra"?

+4
source share
3 answers

Sinatra is a lightweight library whose goal is to stay away from your path, leaving the door open for you to include or create what you need for each project.

However, you can easily create your own MVC on top of Sinatra and enable ActiveRecord, DataMapper, Sequel, etc. for their models. Here is a sample structure -

β”œβ”€β”€ Gemfile
β”œβ”€β”€ README.md
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ controllers
β”‚   β”‚   └── application_controller.rb
β”‚   β”œβ”€β”€ models
β”‚   β”‚   └── model.rb
β”‚   └── views
β”‚       └── index.erb
β”œβ”€β”€ config
β”‚   └── environment.rb
β”œβ”€β”€ config.ru
β”œβ”€β”€ public
β”‚   └── stylesheets
└── spec
    β”œβ”€β”€ controllers
    β”œβ”€β”€ features
    β”œβ”€β”€ models
    └── spec_helper.rb

Gemfile - where all your gems go.

- MVC - , .

- .

- , , .

- , .

config.ru - config.ru -/ (ru rackup).

Config Directory - w/ environment.rb fileto .

Public Directory - - CSS/JS/Images ..

- .

+2

, Padrino

, Sinatra, "Rails like" , . , Sinatra.

, , Sinatra , . /, , - :

ORM, Sequel, (imho) , .

+4

Sinatra , .

. .

,

  • . datamapper, activerecord .. datamapper , . activerecord .
  • /
  • /views. / . /views/layout.erb , <%= yield %>
+3

All Articles