Code Monkey home page Code Monkey logo

tinderpizza's Introduction

Tinder Pizza Sinatra Demo

bundle exec ruby tinderpizza.rb 

First Lecture

  • What is rack?
  • We're using sinatra
  • bundle init
  • What's in the Gemfile
  • bundle install
  • Blocks must return a string
  • Default status code 200 and content type text/html
  • bundle exec ruby tinderpizza.rb
  • views folder
  • views/layout.erb

Second Lecture Prep

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 demo
    • gem "rake"
  • Add models directory
  • Add models/pizza.rb
class Pizza < ActiveRecord::Base
end
  • autoload :Pizza, settings.root + '/models/pizza'
  • Add db directory
  • Added Rakefile for db tasks
    • and rake console (handy!)
  • Added migration rake db:create_migration NAME=create_pizzas
  • Added Validations
  • Added db/seeds.rb so rake db:seed works
  • Added footer and nav to layout
  • Added static /about_us route
  • Added controllers/pizza_controller.rb

Nested Routes

  • Toppings Belong to Pizzas
  • controlers/topping_controller.rb
  • views/toppings

Secret Random Keys

  • models/pizza.rb - before_create
  • db/migrate/XXX_add_secret_key_to_pizzas.rb

tinderpizza's People

Contributors

stujo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.