-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
454 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# Place all the behaviors and hooks related to the matching controller here. | |||
# All this logic will automatically be available in application.js. | |||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# Place all the behaviors and hooks related to the matching controller here. | |||
# All this logic will automatically be available in application.js. | |||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
// Place all the styles related to the Tabs controller here. | |||
// They will automatically be included in application.css. | |||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
// Place all the styles related to the TallySheets controller here. | |||
// They will automatically be included in application.css. | |||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
class BeveragesController < ApplicationController | |||
before_action :set_beverage, only: [:show, :edit, :update, :destroy] | |||
|
|||
# GET /beverages | |||
def index | |||
@beverages = Beverage.all | |||
end | |||
|
|||
# GET /beverages/1 | |||
def show | |||
end | |||
|
|||
# GET /beverages/new | |||
def new | |||
@beverage = Beverage.new | |||
end | |||
|
|||
# GET /beverages/1/edit | |||
def edit | |||
end | |||
|
|||
# POST /beverages | |||
def create | |||
@beverage = Beverage.new(beverage_params) | |||
|
|||
if @beverage.save | |||
redirect_to @beverage, notice: 'Beverage was successfully created.' | |||
else | |||
render action: 'new' | |||
end | |||
end | |||
|
|||
# PATCH/PUT /beverages/1 | |||
def update | |||
if @beverage.update(beverage_params) | |||
redirect_to @beverage, notice: 'Beverage was successfully updated.' | |||
else | |||
render action: 'edit' | |||
end | |||
end | |||
|
|||
# DELETE /beverages/1 | |||
def destroy | |||
@beverage.destroy | |||
redirect_to beverages_url, notice: 'Beverage was successfully destroyed.' | |||
end | |||
|
|||
private | |||
# Use callbacks to share common setup or constraints between actions. | |||
def set_beverage | |||
@beverage = Beverage.find(params[:id]) | |||
end | |||
|
|||
# Never trust parameters from the scary internet, only allow the white list through. | |||
def beverage_params | |||
params.require(:beverage).permit(:name, :description, :available, :price) | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
class TabsController < ApplicationController | |||
def index | |||
end | |||
|
|||
def create | |||
end | |||
|
|||
def show | |||
end | |||
|
|||
def update | |||
end | |||
|
|||
def new | |||
@tab.beverages << Beverage.available | |||
end | |||
|
|||
private | |||
# Use callbacks to share common setup or constraints between actions. | |||
def set_tab | |||
@tab = Tab.find(params[:id]) | |||
end | |||
|
|||
# Never trust parameters from the scary internet, only allow the white list through. | |||
def tab_params | |||
params.require(:tab) | |||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
class TallySheetsController < ApplicationController | |||
before_action :get_users, :get_beverages | |||
def index | |||
end | |||
|
|||
def new | |||
@users.each do |user| | |||
user.tabs << Tab.new | |||
end | |||
end | |||
|
|||
def create | |||
end | |||
|
|||
private | |||
# TODO: get only the right users | |||
def get_users | |||
@users = User.all | |||
end | |||
|
|||
def get_beverages | |||
@beverages = Beverage.all.where(:available => true) | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module BeveragesHelper | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module TabsHelper | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module TallySheetsHelper | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
# == Schema Information | |||
# | |||
# Table name: beverages | |||
# | |||
# id :integer not null, primary key | |||
# name :string(255) | |||
# description :text | |||
# available :boolean | |||
# price :decimal(8, 2) | |||
# created_at :datetime | |||
# updated_at :datetime | |||
# | |||
|
|||
class Beverage < ActiveRecord::Base | |||
has_many :beverage_tabs | |||
has_many :tabs, :through => :beverage_tabs | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
class BeverageTab < ActiveRecord::Base | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
class Tab < ActiveRecord::Base | |||
has_many :beverage_tabs | |||
has_many :beverages, :through => :beverage_tabs | |||
belongs_to :user | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
%div | |||
= beverage.name | |||
= beverage.description | |||
= beverage.price | |||
= beverage.available | |||
= link_to 'Edit', edit_beverage_path(beverage) | |||
= link_to 'Delete', beverage_path(beverage), :method => :delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
<%= form_for(@beverage) do |f| %> | |||
<% if @beverage.errors.any? %> | |||
<div id="error_explanation"> | |||
<h2><%= pluralize(@beverage.errors.count, "error") %> prohibited this beverage from being saved:</h2> | |||
|
|||
<ul> | |||
<% @beverage.errors.full_messages.each do |msg| %> | |||
<li><%= msg %></li> | |||
<% end %> | |||
</ul> | |||
</div> | |||
<% end %> | |||
|
|||
<div class="actions"> | |||
<%= f.label :name %> | |||
<%= f.text_field :name %><br /> | |||
|
|||
<%= f.label :description %> | |||
<%= f.text_area :description %><br /> | |||
|
|||
<%= f.label :price %> | |||
<%= f.text_field :price %><br /> | |||
|
|||
<%= f.label :available %> | |||
<%= f.check_box :available %><br /> | |||
|
|||
<%= f.submit %> | |||
</div> | |||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<h1>Editing beverage</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Show', @beverage %> | | |||
<%= link_to 'Back', beverages_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
<h1>Listing beverages</h1> | |||
|
|||
<%= render @beverages %> | |||
|
|||
<br /> | |||
|
|||
<%= link_to 'New Beverage', new_beverage_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<h1>New beverage</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Back', beverages_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<p id="notice"><%= notice %></p> | |||
|
|||
|
|||
<%= link_to 'Edit', edit_beverage_path(@beverage) %> | | |||
<%= link_to 'Back', beverages_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
%div | |||
- @users.each do |user| | |||
= form_for [user,tab=user.tabs.build] do |f| | |||
- @beverages.each do |beverage| | |||
= f.fields_for [beverage, tab.beverage_tabs.build] do |b| | |||
= b.text_field :count | |||
= f.submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
class CreateBeverages < ActiveRecord::Migration | |||
def change | |||
create_table :beverages do |t| | |||
t.string :name | |||
t.text :description | |||
t.boolean :available | |||
t.decimal :price, :precision => 8, :scale => 2 | |||
|
|||
t.timestamps | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
class CreateTabs < ActiveRecord::Migration | |||
def change | |||
create_table :tabs do |t| | |||
t.integer :user_id | |||
|
|||
t.timestamps | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
class CreateBeverageTabs < ActiveRecord::Migration | |||
def change | |||
create_table :beverage_tabs do |t| | |||
t.integer :beverage_id | |||
t.integer :tab_id | |||
t.integer :count | |||
t.decimal :price, :precision => 8, :scale => 2 | |||
|
|||
t.timestamps | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
class CreateUserTabsJoinTable < ActiveRecord::Migration | |||
def change | |||
create_table :user_tabs, :id => false do |t| | |||
t.integer :user_id | |||
t.integer :tab_id | |||
end | |||
add_index :user_tabs, [:user_id, :tab_id], :unique => true | |||
end | |||
end |
Oops, something went wrong.