bundle exec ruby tinderpizza.rb
- What is
rack? - We're using
sinatra bundle init- What's in the
Gemfile bundle install- Blocks must return a string
- Default status code
200andcontent type text/html bundle exec ruby tinderpizza.rbviewsfolderviews/layout.erb
This is slightly different than the Sinatra Skeleton App so you can compare. I'm using sinatra-activerecord gem to save me some steps. Note; the rake db:create_migration task is different from your code. Because I'm using require "sinatra/activerecord/rake" in the Rakefile instead of writing tasks by hand.
- Add gems
gem "sinatra-activerecord"gem "sqlite3"- don't need postgres for demogem "rake"
- Add
modelsdirectory - Add
models/pizza.rb
class Pizza < ActiveRecord::Base
end
autoload :Pizza, settings.root + '/models/pizza'- Add
dbdirectory - Added
Rakefilefor db tasks- and
rake console(handy!)
- and
- Added migration
rake db:create_migration NAME=create_pizzas - Added Validations
- Added
db/seeds.rbsorake db:seedworks - Added footer and nav to layout
- Added static
/about_usroute - Added
controllers/pizza_controller.rb
- Toppings Belong to Pizzas
controlers/topping_controller.rbviews/toppings
models/pizza.rb-before_createdb/migrate/XXX_add_secret_key_to_pizzas.rb
- RSpec to test Sinatra
- Need to support different databases for testing and development
- Use
RACK_ENV - Look at the
set :databaseline intinderpizza.rb RACK_ENV=test rake db:createRACK_ENV=test rake db:migrate
- Use
- Create specs in folders underneath
./specfolder bundle exec rspec