-
Notifications
You must be signed in to change notification settings - Fork 0
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
17 changed files
with
2,344 additions
and
296 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class PressShiftController < ApplicationController | ||
def index | ||
@cookie = cookies[:pressed] | ||
end | ||
|
||
def press | ||
if params[:button] == "left" | ||
$redis.incr('left_count') | ||
elsif params[:button] == "right" | ||
$redis.incr('right_count') | ||
end | ||
cookies.permanent[:pressed] = params[:button] | ||
redirect_to root_path | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PressShiftHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%h1 | ||
Which Shift Button? | ||
|
||
- if @cookie | ||
%p | ||
Left Count: | ||
= $redis.get('left_count') | ||
%p | ||
Right Count: | ||
= $redis.get('right_count') | ||
|
||
- else | ||
= link_to "Left", press_path(:button => "left"), :method => :post | ||
= link_to "Right", press_path(:button => "right"), :method => :post |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$redis = Redis.new(:host => 'localhost', :port => 6379) |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,4 @@ | ||
WhichShiftButton::Application.routes.draw do | ||
# The priority is based upon order of creation: | ||
# first created -> highest priority. | ||
|
||
# Sample of regular route: | ||
# match 'products/:id' => 'catalog#view' | ||
# Keep in mind you can assign values other than :controller and :action | ||
|
||
# Sample of named route: | ||
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase | ||
# This route can be invoked with purchase_url(:id => product.id) | ||
|
||
# Sample resource route (maps HTTP verbs to controller actions automatically): | ||
# resources :products | ||
|
||
# Sample resource route with options: | ||
# resources :products do | ||
# member do | ||
# get 'short' | ||
# post 'toggle' | ||
# end | ||
# | ||
# collection do | ||
# get 'sold' | ||
# end | ||
# end | ||
|
||
# Sample resource route with sub-resources: | ||
# resources :products do | ||
# resources :comments, :sales | ||
# resource :seller | ||
# end | ||
|
||
# Sample resource route with more complex sub-resources | ||
# resources :products do | ||
# resources :comments | ||
# resources :sales do | ||
# get 'recent', :on => :collection | ||
# end | ||
# end | ||
|
||
# Sample resource route within a namespace: | ||
# namespace :admin do | ||
# # Directs /admin/products/* to Admin::ProductsController | ||
# # (app/controllers/admin/products_controller.rb) | ||
# resources :products | ||
# end | ||
|
||
# You can have the root of your site routed with "root" | ||
# just remember to delete public/index.html. | ||
# root :to => "welcome#index" | ||
|
||
# See how all your routes lay out with "rake routes" | ||
|
||
# This is a legacy wild controller route that's not recommended for RESTful applications. | ||
# Note: This route will make all actions in every controller accessible via GET requests. | ||
# match ':controller(/:action(/:id(.:format)))' | ||
root :to => 'press_shift#index' | ||
match '/press' => 'press_shift#press', :as => :press | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 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 to check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(:version => 0) do | ||
|
||
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
Oops, something went wrong.