Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

gem 'hirb'

gem 'haml'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ GEM
coffee-script-source (1.6.3)
erubis (2.7.0)
execjs (2.0.2)
haml (4.0.3)
tilt
hike (1.2.3)
hirb (0.7.1)
i18n (0.6.5)
jbuilder (1.5.2)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -116,6 +119,8 @@ PLATFORMS

DEPENDENCIES
coffee-rails (~> 4.0.0)
haml
hirb
jbuilder (~> 1.2)
jquery-rails
pry
Expand Down
30 changes: 5 additions & 25 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
== README
• Create a resturaunt menu using Ruby on Rails

This README would normally document whatever steps are necessary to get the
application up and running.
• Homepage should list all menu items

Things you may want to cover:
• Each menu item should have a name, a price, and a list of ingredients

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...


Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
• User should be able to add menu items at the bottom of the homepage
• Technology: Ruby on Rails and Haml
18 changes: 18 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
body {
background-color: #dbe3eb;
}

h1 {
text-align: center;
font-family: molesk;
font-size: 3em;
}

td {
text-align: center;
}

a {
text-decoration: none;
}

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
Expand Down
4 changes: 4 additions & 0 deletions app/models/ingredient.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Ingredient < ActiveRecord::Base
has_many :recipes
has_many :menu_items, :through => :recipes
end
4 changes: 3 additions & 1 deletion app/models/menu_item.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
class MenuItem < ActiveRecord::Base
class MenuItem < ActiveRecord::Base
has_many :recipes
has_many :ingredients, :through => :recipes
end
4 changes: 4 additions & 0 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Recipe < ActiveRecord::Base
belongs_to :menu_item
belongs_to :ingredient
end
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
</head>
<body>

<h1>MAKERSBISTRO</h1>

<%= yield %>

</body>
Expand Down
26 changes: 0 additions & 26 deletions app/views/menu_items/index.html.erb

This file was deleted.

23 changes: 23 additions & 0 deletions app/views/menu_items/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%h1 Now Serving:

%table
%thead
%tr
%th
%th
%th
%th

%tbody
-@menu_items.each do |menu_item|
%tr
%td= menu_item.name
%td= menu_item.price
%td= link_to 'Show', menu_item
%td= link_to 'Edit', edit_menu_item_path(menu_item)
%td= link_to 'Destroy', menu_item, data: { method: :delete }

%br

= link_to 'New Menu item', new_menu_item_path

57 changes: 5 additions & 52 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,56 +1,9 @@
Makerbistro::Application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
resources :menu_items do
resources :recipes
end

# You can have the root of your site routed with "root"
# root 'welcome#index'
resources :ingredients, only: [:show]

# Example of regular route:
# get 'products/:id' => 'catalog#view'

# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end

# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable

# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
root 'menu_items#index'
end
1 change: 1 addition & 0 deletions db/migrate/20131010155724_create_menu_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class CreateMenuItems < ActiveRecord::Migration
def change
create_table :menu_items do |t|
t.string :name
t.string :price
t.timestamps
end
end
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20131011162357_create_recipes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateRecipes < ActiveRecord::Migration
def change
create_table :recipes do |t|
t.references :menu_item
t.references :ingredient

t.timestamps
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20131011162407_create_ingredients.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateIngredients < ActiveRecord::Migration
def change
create_table :ingredients do |t|
t.string :name

t.timestamps
end
end
end
36 changes: 36 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20131011162407) do

create_table "ingredients", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "menu_items", force: true do |t|
t.string "name"
t.string "price"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "recipes", force: true do |t|
t.integer "menu_item_id"
t.integer "ingredient_id"
t.datetime "created_at"
t.datetime "updated_at"
end

end
Binary file added public/stitched_wool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions test/fixtures/ingredients.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
11 changes: 11 additions & 0 deletions test/fixtures/recipes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
7 changes: 7 additions & 0 deletions test/models/ingredient_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class IngredientTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/recipe_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class RecipeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end