my_little_fox my_little_fox - 2 years ago 127
Ruby Question

MVC pattern for sinatra frame work

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?

Answer Source

Sinatra is simple enough that you can fit the models and controllers in one file.

See here for a very brief guide for how to do it.

To summarize some points,

  • connect to database and write models. you can use datamapper, activerecord, etc for this. datamapper is nice because you don't need to write migrations. but activerecord has a better query interface.
  • write controller actions / routes
  • write views in the /views directory. assets go in the /public directory. /views/layout.erb can be used as a layout if it contains <%= yield %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download