I want to start coding with 'Sinatra' framework but i cant find a 'MVC' pattern for this framework . Is an 'MVC-Sinatra' pattern or framework?
You might want to check out Padrino
This is a framework built around Sinatra that provides a more "Rails like" feel to your project, but without as much hidden magic. It is a great example of what can be done with Sinatra.
Whilst this is great if you need to just get going, I would personally recommend that you use it as a learning tool to build your own apps using Sinatra in the way that makes the most sense to you. Write some tests / expectations, write some code, pass the tests - repeat :)
As for the ORM, you should also checkout Sequel which (imho) is very straight forward yet very flexible and powerful.
Sinatra is a lightweight library, that aims to stay out of your way, leaving the door open for you to include or create what you need per project.
That said, you can create your own MVC on top of Sinatra rather easily, and incorporate ActiveRecord, DataMapper, Sequel, etc... for your Models. Here's 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.
App Directory - folder for MVC directories - models, views, and controllers.
Models Directory - holds the logic behind your application.
Controllers Directory - where the application configurations, routes, and controller actions are implemented.
Views Directory - holds the code that will be displayed in the browser.
config.ru - the config.ru
file is necessary when building Rack-based applications and using rackup/shotgun to start the application server (the ru stands for rackup
).
Config Directory - w/ environment.rb
fileto connect up all the files in your application to the appropriate gems and to each other.
Public Directory - holds your front-end assets - CSS / JS / Images, etc...
Spec Directory - contains any tests for your applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With