bundle install.
shotgun.
tux.
localhost:9393in your browser.
Sinatra apps can be built a bunch of different ways. This is my way. I think it's pretty good.
Appthat extends
Sinatra::Application. It is wrapped in a module that you should name with your project name.
config.rufile. All we need to do in there is require our
app.rbfile and then run it:
sinatragem. This, and all of your Gemfiles are required in your app using Bundler at the very top of your
app.rb:
publicfolder for all our static assets (i.e. things that don't need to be compiled or rendered, like pictures and css.) We'll also define a
:root. This goes inside our
Appclass definition in the
app.rbfile.
Hell yes you can use ActiveRecord, even if you aren't in Rails. The structure Rat Pack provides is explained below. If you want more info on how to properly implement RESTful resources with AR in Sinatra, czech out this awesome tutorial.
database.dbto something more related to your project.
libdirectory are required in your app using this code:
ActiveRecord::Baselike this:
Appclass in
app.rb. The Pack contains one as an example:
layout.erbfile in the
viewsfolder. The one the Pack contains is shown below: Note that whatever view you render will be inserted into the layout where
<%= yield %>is.
Ashley Williams
made Rat Pack for her students at the Flatiron School
.
If you find an issue, please report it on github.