Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit

  • Loading branch information...
commit 9a298eb44c25f105a9381b0a45b9577b060c7d51 0 parents
Ryan Bates ryanb authored

Showing 127 changed files with 1,905 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  README
  2. +5 0 store-after/.gitignore
  3. +17 0 store-after/Gemfile
  4. +118 0 store-after/Gemfile.lock
  5. +7 0 store-after/README
  6. +7 0 store-after/Rakefile
  7. BIN  store-after/app/assets/images/rails.png
  8. +9 0 store-after/app/assets/javascripts/application.js
  9. +3 0  store-after/app/assets/javascripts/products.js.coffee
  10. +136 0 store-after/app/assets/stylesheets/application.css.scss
  11. +3 0  store-after/app/assets/stylesheets/products.css.scss
  12. +3 0  store-after/app/controllers/application_controller.rb
  13. +41 0 store-after/app/controllers/products_controller.rb
  14. +2 0  store-after/app/helpers/application_helper.rb
  15. +2 0  store-after/app/helpers/products_helper.rb
  16. 0  store-after/app/mailers/.gitkeep
  17. 0  store-after/app/models/.gitkeep
  18. +2 0  store-after/app/models/product.rb
  19. +17 0 store-after/app/views/layouts/application.html.erb
  20. +29 0 store-after/app/views/products/_form.html.erb
  21. +6 0 store-after/app/views/products/edit.html.erb
  22. +23 0 store-after/app/views/products/index.html.erb
  23. +5 0 store-after/app/views/products/new.html.erb
  24. +20 0 store-after/app/views/products/show.html.erb
  25. +4 0 store-after/config.ru
  26. +48 0 store-after/config/application.rb
  27. +6 0 store-after/config/boot.rb
  28. +25 0 store-after/config/database.yml
  29. +5 0 store-after/config/environment.rb
  30. +30 0 store-after/config/environments/development.rb
  31. +60 0 store-after/config/environments/production.rb
  32. +42 0 store-after/config/environments/test.rb
  33. +7 0 store-after/config/initializers/backtrace_silencers.rb
  34. +10 0 store-after/config/initializers/inflections.rb
  35. +5 0 store-after/config/initializers/mime_types.rb
  36. +7 0 store-after/config/initializers/secret_token.rb
  37. +8 0 store-after/config/initializers/session_store.rb
  38. +14 0 store-after/config/initializers/wrap_parameters.rb
  39. +5 0 store-after/config/locales/en.yml
  40. +4 0 store-after/config/routes.rb
  41. +11 0 store-after/db/migrate/20111005175852_create_products.rb
  42. +24 0 store-after/db/schema.rb
  43. +34 0 store-after/db/seeds.rb
  44. +2 0  store-after/doc/README_FOR_APP
  45. 0  store-after/lib/assets/.gitkeep
  46. 0  store-after/lib/tasks/.gitkeep
  47. 0  store-after/log/.gitkeep
  48. +26 0 store-after/public/404.html
  49. +26 0 store-after/public/422.html
  50. +26 0 store-after/public/500.html
  51. 0  store-after/public/favicon.ico
  52. +5 0 store-after/public/robots.txt
  53. +6 0 store-after/script/rails
  54. 0  store-after/test/fixtures/.gitkeep
  55. 0  store-after/test/functional/.gitkeep
  56. +49 0 store-after/test/functional/products_controller_test.rb
  57. 0  store-after/test/integration/.gitkeep
  58. +12 0 store-after/test/performance/browsing_test.rb
  59. +13 0 store-after/test/test_helper.rb
  60. 0  store-after/test/unit/.gitkeep
  61. +4 0 store-after/test/unit/helpers/products_helper_test.rb
  62. +7 0 store-after/test/unit/product_test.rb
  63. 0  store-after/vendor/assets/stylesheets/.gitkeep
  64. 0  store-after/vendor/plugins/.gitkeep
  65. +5 0 store-before/.gitignore
  66. +15 0 store-before/Gemfile
  67. +116 0 store-before/Gemfile.lock
  68. +7 0 store-before/README
  69. +7 0 store-before/Rakefile
  70. BIN  store-before/app/assets/images/rails.png
  71. +9 0 store-before/app/assets/javascripts/application.js
  72. +3 0  store-before/app/assets/javascripts/products.js.coffee
  73. +92 0 store-before/app/assets/stylesheets/application.css.scss
  74. +3 0  store-before/app/assets/stylesheets/products.css.scss
  75. +3 0  store-before/app/controllers/application_controller.rb
  76. +41 0 store-before/app/controllers/products_controller.rb
  77. +2 0  store-before/app/helpers/application_helper.rb
  78. +2 0  store-before/app/helpers/products_helper.rb
  79. 0  store-before/app/mailers/.gitkeep
  80. 0  store-before/app/models/.gitkeep
  81. +2 0  store-before/app/models/product.rb
  82. +17 0 store-before/app/views/layouts/application.html.erb
  83. +29 0 store-before/app/views/products/_form.html.erb
  84. +6 0 store-before/app/views/products/edit.html.erb
  85. +13 0 store-before/app/views/products/index.html.erb
  86. +5 0 store-before/app/views/products/new.html.erb
  87. +20 0 store-before/app/views/products/show.html.erb
  88. +4 0 store-before/config.ru
  89. +48 0 store-before/config/application.rb
  90. +6 0 store-before/config/boot.rb
  91. +25 0 store-before/config/database.yml
  92. +5 0 store-before/config/environment.rb
  93. +30 0 store-before/config/environments/development.rb
  94. +60 0 store-before/config/environments/production.rb
  95. +42 0 store-before/config/environments/test.rb
  96. +7 0 store-before/config/initializers/backtrace_silencers.rb
  97. +10 0 store-before/config/initializers/inflections.rb
  98. +5 0 store-before/config/initializers/mime_types.rb
  99. +7 0 store-before/config/initializers/secret_token.rb
  100. +8 0 store-before/config/initializers/session_store.rb
  101. +14 0 store-before/config/initializers/wrap_parameters.rb
  102. +5 0 store-before/config/locales/en.yml
  103. +4 0 store-before/config/routes.rb
  104. +11 0 store-before/db/migrate/20111005175852_create_products.rb
  105. +24 0 store-before/db/schema.rb
  106. +34 0 store-before/db/seeds.rb
  107. +2 0  store-before/doc/README_FOR_APP
  108. 0  store-before/lib/assets/.gitkeep
  109. 0  store-before/lib/tasks/.gitkeep
  110. 0  store-before/log/.gitkeep
  111. +26 0 store-before/public/404.html
  112. +26 0 store-before/public/422.html
  113. +26 0 store-before/public/500.html
  114. 0  store-before/public/favicon.ico
  115. +5 0 store-before/public/robots.txt
  116. +6 0 store-before/script/rails
  117. 0  store-before/test/fixtures/.gitkeep
  118. 0  store-before/test/functional/.gitkeep
  119. +49 0 store-before/test/functional/products_controller_test.rb
  120. 0  store-before/test/integration/.gitkeep
  121. +12 0 store-before/test/performance/browsing_test.rb
  122. +13 0 store-before/test/test_helper.rb
  123. 0  store-before/test/unit/.gitkeep
  124. +4 0 store-before/test/unit/helpers/products_helper_test.rb
  125. +7 0 store-before/test/unit/product_test.rb
  126. 0  store-before/vendor/assets/stylesheets/.gitkeep
  127. 0  store-before/vendor/plugins/.gitkeep
3  README
... ... @@ -0,0 +1,3 @@
  1 +RailsCasts Episode #51: will_paginate (revised)
  2 +
  3 +http://railscasts.com/episodes/51-will-paginate-revised
5 store-after/.gitignore
... ... @@ -0,0 +1,5 @@
  1 +.bundle
  2 +db/*.sqlite3
  3 +log/*.log
  4 +tmp/
  5 +.sass-cache/
17 store-after/Gemfile
... ... @@ -0,0 +1,17 @@
  1 +source 'http://rubygems.org'
  2 +
  3 +gem 'rails', '3.1.0'
  4 +gem 'rack', '1.3.3' # temporarily to hide warning
  5 +gem 'sqlite3'
  6 +
  7 +# Gems used only for assets and not required
  8 +# in production environments by default.
  9 +group :assets do
  10 + gem 'sass-rails', " ~> 3.1.0"
  11 + gem 'coffee-rails', "~> 3.1.0"
  12 + gem 'uglifier'
  13 +end
  14 +
  15 +gem 'jquery-rails'
  16 +
  17 +gem 'will_paginate', '> 3.0'
118 store-after/Gemfile.lock
... ... @@ -0,0 +1,118 @@
  1 +GEM
  2 + remote: http://rubygems.org/
  3 + specs:
  4 + actionmailer (3.1.0)
  5 + actionpack (= 3.1.0)
  6 + mail (~> 2.3.0)
  7 + actionpack (3.1.0)
  8 + activemodel (= 3.1.0)
  9 + activesupport (= 3.1.0)
  10 + builder (~> 3.0.0)
  11 + erubis (~> 2.7.0)
  12 + i18n (~> 0.6)
  13 + rack (~> 1.3.2)
  14 + rack-cache (~> 1.0.3)
  15 + rack-mount (~> 0.8.2)
  16 + rack-test (~> 0.6.1)
  17 + sprockets (~> 2.0.0)
  18 + activemodel (3.1.0)
  19 + activesupport (= 3.1.0)
  20 + bcrypt-ruby (~> 3.0.0)
  21 + builder (~> 3.0.0)
  22 + i18n (~> 0.6)
  23 + activerecord (3.1.0)
  24 + activemodel (= 3.1.0)
  25 + activesupport (= 3.1.0)
  26 + arel (~> 2.2.1)
  27 + tzinfo (~> 0.3.29)
  28 + activeresource (3.1.0)
  29 + activemodel (= 3.1.0)
  30 + activesupport (= 3.1.0)
  31 + activesupport (3.1.0)
  32 + multi_json (~> 1.0)
  33 + arel (2.2.1)
  34 + bcrypt-ruby (3.0.1)
  35 + builder (3.0.0)
  36 + coffee-rails (3.1.1)
  37 + coffee-script (>= 2.2.0)
  38 + railties (~> 3.1.0)
  39 + coffee-script (2.2.0)
  40 + coffee-script-source
  41 + execjs
  42 + coffee-script-source (1.1.2)
  43 + erubis (2.7.0)
  44 + execjs (1.2.9)
  45 + multi_json (~> 1.0)
  46 + hike (1.2.1)
  47 + i18n (0.6.0)
  48 + jquery-rails (1.0.14)
  49 + railties (~> 3.0)
  50 + thor (~> 0.14)
  51 + mail (2.3.0)
  52 + i18n (>= 0.4.0)
  53 + mime-types (~> 1.16)
  54 + treetop (~> 1.4.8)
  55 + mime-types (1.16)
  56 + multi_json (1.0.3)
  57 + polyglot (0.3.2)
  58 + rack (1.3.3)
  59 + rack-cache (1.0.3)
  60 + rack (>= 0.4)
  61 + rack-mount (0.8.3)
  62 + rack (>= 1.0.0)
  63 + rack-ssl (1.3.2)
  64 + rack
  65 + rack-test (0.6.1)
  66 + rack (>= 1.0)
  67 + rails (3.1.0)
  68 + actionmailer (= 3.1.0)
  69 + actionpack (= 3.1.0)
  70 + activerecord (= 3.1.0)
  71 + activeresource (= 3.1.0)
  72 + activesupport (= 3.1.0)
  73 + bundler (~> 1.0)
  74 + railties (= 3.1.0)
  75 + railties (3.1.0)
  76 + actionpack (= 3.1.0)
  77 + activesupport (= 3.1.0)
  78 + rack-ssl (~> 1.3.2)
  79 + rake (>= 0.8.7)
  80 + rdoc (~> 3.4)
  81 + thor (~> 0.14.6)
  82 + rake (0.9.2)
  83 + rdoc (3.9.4)
  84 + sass (3.1.8)
  85 + sass-rails (3.1.4)
  86 + actionpack (~> 3.1.0)
  87 + railties (~> 3.1.0)
  88 + sass (>= 3.1.4)
  89 + sprockets (~> 2.0.0)
  90 + tilt (~> 1.3.2)
  91 + sprockets (2.0.2)
  92 + hike (~> 1.2)
  93 + rack (~> 1.0)
  94 + tilt (~> 1.1, != 1.3.0)
  95 + sqlite3 (1.3.4)
  96 + thor (0.14.6)
  97 + tilt (1.3.3)
  98 + treetop (1.4.10)
  99 + polyglot
  100 + polyglot (>= 0.3.1)
  101 + tzinfo (0.3.30)
  102 + uglifier (1.0.3)
  103 + execjs (>= 0.3.0)
  104 + multi_json (>= 1.0.2)
  105 + will_paginate (3.0.2)
  106 +
  107 +PLATFORMS
  108 + ruby
  109 +
  110 +DEPENDENCIES
  111 + coffee-rails (~> 3.1.0)
  112 + jquery-rails
  113 + rack (= 1.3.3)
  114 + rails (= 3.1.0)
  115 + sass-rails (~> 3.1.0)
  116 + sqlite3
  117 + uglifier
  118 + will_paginate (> 3.0)
7 store-after/README
... ... @@ -0,0 +1,7 @@
  1 += RailsCasts Example Application
  2 +
  3 +Run these commands to try it out.
  4 +
  5 + bundle
  6 + rake db:setup
  7 + rails s
7 store-after/Rakefile
... ... @@ -0,0 +1,7 @@
  1 +#!/usr/bin/env rake
  2 +# Add your own tasks in files placed in lib/tasks ending in .rake,
  3 +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
  4 +
  5 +require File.expand_path('../config/application', __FILE__)
  6 +
  7 +Store::Application.load_tasks
BIN  store-after/app/assets/images/rails.png
9 store-after/app/assets/javascripts/application.js
... ... @@ -0,0 +1,9 @@
  1 +// This is a manifest file that'll be compiled into including all the files listed below.
  2 +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
  3 +// be included in the compiled file accessible from http://example.com/assets/application.js
  4 +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  5 +// the compiled file.
  6 +//
  7 +//= require jquery
  8 +//= require jquery_ujs
  9 +//= require_tree .
3  store-after/app/assets/javascripts/products.js.coffee
... ... @@ -0,0 +1,3 @@
  1 +# Place all the behaviors and hooks related to the matching controller here.
  2 +# All this logic will automatically be available in application.js.
  3 +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
136 store-after/app/assets/stylesheets/application.css.scss
... ... @@ -0,0 +1,136 @@
  1 +/*
  2 + * This is a manifest file that'll automatically include all the stylesheets available in this directory
  3 + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
  4 + * the top of the compiled file, but it's generally better to create a new file per style scope.
  5 + *= require_self
  6 + *= require_tree .
  7 +*/
  8 +
  9 +body {
  10 + background-color: #4B7399;
  11 + font-family: Verdana, Helvetica, Arial;
  12 + font-size: 14px;
  13 +}
  14 +
  15 +a img {
  16 + border: none;
  17 +}
  18 +
  19 +a {
  20 + color: #0000FF;
  21 +}
  22 +
  23 +.clear {
  24 + clear: both;
  25 + height: 0;
  26 + overflow: hidden;
  27 +}
  28 +
  29 +#container {
  30 + width: 75%;
  31 + margin: 0 auto;
  32 + background-color: #FFF;
  33 + padding: 20px 40px;
  34 + border: solid 1px black;
  35 + margin-top: 20px;
  36 +}
  37 +
  38 +#flash_notice, #flash_error, #flash_alert {
  39 + padding: 5px 8px;
  40 + margin: 10px 0;
  41 +}
  42 +
  43 +#flash_notice {
  44 + background-color: #CFC;
  45 + border: solid 1px #6C6;
  46 +}
  47 +
  48 +#flash_error, #flash_alert {
  49 + background-color: #FCC;
  50 + border: solid 1px #C66;
  51 +}
  52 +
  53 +.fieldWithErrors {
  54 + display: inline;
  55 +}
  56 +
  57 +.error_messages {
  58 + width: 400px;
  59 + border: 2px solid #CF0000;
  60 + padding: 0px;
  61 + padding-bottom: 12px;
  62 + margin-bottom: 20px;
  63 + background-color: #f0f0f0;
  64 + font-size: 12px;
  65 +}
  66 +
  67 +.error_messages h2 {
  68 + text-align: left;
  69 + font-weight: bold;
  70 + padding: 5px 10px;
  71 + font-size: 12px;
  72 + margin: 0;
  73 + background-color: #c00;
  74 + color: #fff;
  75 +}
  76 +
  77 +.error_messages p {
  78 + margin: 8px 10px;
  79 +}
  80 +
  81 +.error_messages ul {
  82 + margin: 0;
  83 +}
  84 +
  85 +form .field, form .actions {
  86 + margin: 12px 0;
  87 +}
  88 +
  89 +.product h2 {
  90 + font-size: 16px;
  91 + margin-bottom: 2px;
  92 +}
  93 +
  94 +.pagination {
  95 + background: white;
  96 + cursor: default;
  97 + height: 22px;
  98 + a, span, em {
  99 + padding: 0.2em 0.5em;
  100 + display: block;
  101 + float: left;
  102 + margin-right: 1px;
  103 + }
  104 + .disabled {
  105 + display: none;
  106 + }
  107 + .current {
  108 + font-style: normal;
  109 + font-weight: bold;
  110 + background: #2e6ab1;
  111 + color: white;
  112 + border: 1px solid #2e6ab1;
  113 + }
  114 + a {
  115 + text-decoration: none;
  116 + color: #105cb6;
  117 + border: 1px solid #9aafe5;
  118 + &:hover, &:focus {
  119 + color: #000033;
  120 + border-color: #000033;
  121 + }
  122 + }
  123 + .page_info {
  124 + background: #2e6ab1;
  125 + color: white;
  126 + padding: 0.4em 0.6em;
  127 + width: 22em;
  128 + margin-bottom: 0.3em;
  129 + text-align: center;
  130 + b {
  131 + color: #000033;
  132 + background: #2e6ab1 + 60;
  133 + padding: 0.1em 0.25em;
  134 + }
  135 + }
  136 +}
3  store-after/app/assets/stylesheets/products.css.scss
... ... @@ -0,0 +1,3 @@
  1 +// Place all the styles related to the products controller here.
  2 +// They will automatically be included in application.css.
  3 +// You can use Sass (SCSS) here: http://sass-lang.com/
3  store-after/app/controllers/application_controller.rb
... ... @@ -0,0 +1,3 @@
  1 +class ApplicationController < ActionController::Base
  2 + protect_from_forgery
  3 +end
41 store-after/app/controllers/products_controller.rb
... ... @@ -0,0 +1,41 @@
  1 +class ProductsController < ApplicationController
  2 + def index
  3 + @products = Product.order("name").page(params[:page]).per_page(5)
  4 + end
  5 +
  6 + def show
  7 + @product = Product.find(params[:id])
  8 + end
  9 +
  10 + def new
  11 + @product = Product.new
  12 + end
  13 +
  14 + def create
  15 + @product = Product.new(params[:product])
  16 + if @product.save
  17 + redirect_to @product, notice: "Successfully created product."
  18 + else
  19 + render :new
  20 + end
  21 + end
  22 +
  23 + def edit
  24 + @product = Product.find(params[:id])
  25 + end
  26 +
  27 + def update
  28 + @product = Product.find(params[:id])
  29 + if @product.update_attributes(params[:product])
  30 + redirect_to @product, notice: "Successfully created product."
  31 + else
  32 + render :edit
  33 + end
  34 + end
  35 +
  36 + def destroy
  37 + @product = Product.find(params[:id])
  38 + @product.destroy
  39 + redirect_to products_url, notice: "Successfully destroyed product."
  40 + end
  41 +end
2  store-after/app/helpers/application_helper.rb
... ... @@ -0,0 +1,2 @@
  1 +module ApplicationHelper
  2 +end
2  store-after/app/helpers/products_helper.rb
... ... @@ -0,0 +1,2 @@
  1 +module ProductsHelper
  2 +end
0  store-after/app/mailers/.gitkeep
No changes.
0  store-after/app/models/.gitkeep
No changes.
2  store-after/app/models/product.rb
... ... @@ -0,0 +1,2 @@
  1 +class Product < ActiveRecord::Base
  2 +end
17 store-after/app/views/layouts/application.html.erb
... ... @@ -0,0 +1,17 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 + <head>
  4 + <title>Store</title>
  5 + <%= stylesheet_link_tag "application" %>
  6 + <%= javascript_include_tag "application" %>
  7 + <%= csrf_meta_tag %>
  8 + </head>
  9 + <body>
  10 + <div id="container">
  11 + <% flash.each do |name, msg| %>
  12 + <%= content_tag :div, msg, :id => "flash_#{name}" %>
  13 + <% end %>
  14 + <%= yield %>
  15 + </div>
  16 + </body>
  17 +</html>
29 store-after/app/views/products/_form.html.erb
... ... @@ -0,0 +1,29 @@
  1 +<%= form_for(@product) do |f| %>
  2 + <% if @product.errors.any? %>
  3 + <div id="error_explanation">
  4 + <h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
  5 +
  6 + <ul>
  7 + <% @product.errors.full_messages.each do |msg| %>
  8 + <li><%= msg %></li>
  9 + <% end %>
  10 + </ul>
  11 + </div>
  12 + <% end %>
  13 +
  14 + <div class="field">
  15 + <%= f.label :name %><br />
  16 + <%= f.text_field :name %>
  17 + </div>
  18 + <div class="field">
  19 + <%= f.label :price %><br />
  20 + <%= f.text_field :price %>
  21 + </div>
  22 + <div class="field">
  23 + <%= f.label :released_at %><br />
  24 + <%= f.date_select :released_at %>
  25 + </div>
  26 + <div class="actions">
  27 + <%= f.submit %>
  28 + </div>
  29 +<% end %>
6 store-after/app/views/products/edit.html.erb
... ... @@ -0,0 +1,6 @@
  1 +<h1>Editing Product</h1>
  2 +
  3 +<%= render 'form' %>
  4 +
  5 +<%= link_to 'Show', @product %> |
  6 +<%= link_to 'Back', products_path %>
23 store-after/app/views/products/index.html.erb
... ... @@ -0,0 +1,23 @@
  1 +<h1>Products</h1>
  2 +
  3 +<%# will_paginate @products, previous_label: h("<"), next_label: h(">") %>
  4 +
  5 +<% if @products.previous_page %>
  6 + <%= link_to "< Previous", params.merge(page: @products.previous_page) %>
  7 +<% end %>
  8 +Page <%= @products.current_page %> of <%= @products.total_pages %>
  9 +<% if @products.next_page %>
  10 + <%= link_to "Next >", params.merge(page: @products.next_page) %>
  11 +<% end %>
  12 +
  13 +<% for product in @products %>
  14 + <div class="product">
  15 + <h2><%= link_to product.name, product %></h2>
  16 + <div class="details">
  17 + <%= number_to_currency(product.price) %> |
  18 + Released <%= product.released_at.strftime("%B %e, %Y") %>
  19 + </div>
  20 + </div>
  21 +<% end %>
  22 +
  23 +<p><%= link_to "New Product", new_product_path %></p>
5 store-after/app/views/products/new.html.erb
... ... @@ -0,0 +1,5 @@
  1 +<h1>New Product</h1>
  2 +
  3 +<%= render 'form' %>
  4 +
  5 +<%= link_to 'Back', products_path %>
20 store-after/app/views/products/show.html.erb
... ... @@ -0,0 +1,20 @@
  1 +<p id="notice"><%= notice %></p>
  2 +
  3 +<p>
  4 + <b>Name:</b>
  5 + <%= @product.name %>
  6 +</p>
  7 +
  8 +<p>
  9 + <b>Price:</b>
  10 + <%= @product.price %>
  11 +</p>
  12 +
  13 +<p>
  14 + <b>Released at:</b>
  15 + <%= @product.released_at %>
  16 +</p>
  17 +
  18 +
  19 +<%= link_to 'Edit', edit_product_path(@product) %> |
  20 +<%= link_to 'Back', products_path %>
4 store-after/config.ru
... ... @@ -0,0 +1,4 @@
  1 +# This file is used by Rack-based servers to start the application.
  2 +
  3 +require ::File.expand_path('../config/environment', __FILE__)
  4 +run Store::Application
48 store-after/config/application.rb
... ... @@ -0,0 +1,48 @@
  1 +require File.expand_path('../boot', __FILE__)
  2 +
  3 +require 'rails/all'
  4 +
  5 +if defined?(Bundler)
  6 + # If you precompile assets before deploying to production, use this line
  7 + Bundler.require *Rails.groups(:assets => %w(development test))
  8 + # If you want your assets lazily compiled in production, use this line
  9 + # Bundler.require(:default, :assets, Rails.env)
  10 +end
  11 +
  12 +module Store
  13 + class Application < Rails::Application
  14 + # Settings in config/environments/* take precedence over those specified here.
  15 + # Application configuration should go into files in config/initializers
  16 + # -- all .rb files in that directory are automatically loaded.
  17 +
  18 + # Custom directories with classes and modules you want to be autoloadable.
  19 + # config.autoload_paths += %W(#{config.root}/extras)
  20 +
  21 + # Only load the plugins named here, in the order given (default is alphabetical).
  22 + # :all can be used as a placeholder for all plugins not explicitly named.
  23 + # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
  24 +
  25 + # Activate observers that should always be running.
  26 + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
  27 +
  28 + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  29 + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  30 + # config.time_zone = 'Central Time (US & Canada)'
  31 +
  32 + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
  33 + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  34 + # config.i18n.default_locale = :de
  35 +
  36 + # Configure the default encoding used in templates for Ruby 1.9.
  37 + config.encoding = "utf-8"
  38 +
  39 + # Configure sensitive parameters which will be filtered from the log file.
  40 + config.filter_parameters += [:password]
  41 +
  42 + # Enable the asset pipeline
  43 + config.assets.enabled = true
  44 +
  45 + # Version of your assets, change this if you want to expire all your assets
  46 + config.assets.version = '1.0'
  47 + end
  48 +end
6 store-after/config/boot.rb
... ... @@ -0,0 +1,6 @@
  1 +require 'rubygems'
  2 +
  3 +# Set up gems listed in the Gemfile.
  4 +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
  5 +
  6 +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
25 store-after/config/database.yml
... ... @@ -0,0 +1,25 @@
  1 +# SQLite version 3.x
  2 +# gem install sqlite3
  3 +#
  4 +# Ensure the SQLite 3 gem is defined in your Gemfile
  5 +# gem 'sqlite3'
  6 +development:
  7 + adapter: sqlite3
  8 + database: db/development.sqlite3
  9 + pool: 5
  10 + timeout: 5000
  11 +
  12 +# Warning: The database defined as "test" will be erased and
  13 +# re-generated from your development database when you run "rake".
  14 +# Do not set this db to the same as development or production.
  15 +test:
  16 + adapter: sqlite3
  17 + database: db/test.sqlite3
  18 + pool: 5
  19 + timeout: 5000
  20 +
  21 +production:
  22 + adapter: sqlite3
  23 + database: db/production.sqlite3
  24 + pool: 5
  25 + timeout: 5000
5 store-after/config/environment.rb
... ... @@ -0,0 +1,5 @@
  1 +# Load the rails application
  2 +require File.expand_path('../application', __FILE__)
  3 +
  4 +# Initialize the rails application
  5 +Store::Application.initialize!
30 store-after/config/environments/development.rb
... ... @@ -0,0 +1,30 @@
  1 +Store::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # In the development environment your application's code is reloaded on
  5 + # every request. This slows down response time but is perfect for development
  6 + # since you don't have to restart the web server when you make code changes.
  7 + config.cache_classes = false
  8 +
  9 + # Log error messages when you accidentally call methods on nil.
  10 + config.whiny_nils = true
  11 +
  12 + # Show full error reports and disable caching
  13 + config.consider_all_requests_local = true
  14 + config.action_controller.perform_caching = false
  15 +
  16 + # Don't care if the mailer can't send
  17 + config.action_mailer.raise_delivery_errors = false
  18 +
  19 + # Print deprecation notices to the Rails logger
  20 + config.active_support.deprecation = :log
  21 +
  22 + # Only use best-standards-support built into browsers
  23 + config.action_dispatch.best_standards_support = :builtin
  24 +
  25 + # Do not compress assets
  26 + config.assets.compress = false
  27 +
  28 + # Expands the lines which load the assets
  29 + config.assets.debug = true
  30 +end
60 store-after/config/environments/production.rb
... ... @@ -0,0 +1,60 @@
  1 +Store::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # Code is not reloaded between requests
  5 + config.cache_classes = true
  6 +
  7 + # Full error reports are disabled and caching is turned on
  8 + config.consider_all_requests_local = false
  9 + config.action_controller.perform_caching = true
  10 +
  11 + # Disable Rails's static asset server (Apache or nginx will already do this)
  12 + config.serve_static_assets = false
  13 +
  14 + # Compress JavaScripts and CSS
  15 + config.assets.compress = true
  16 +
  17 + # Don't fallback to assets pipeline if a precompiled asset is missed
  18 + config.assets.compile = false
  19 +
  20 + # Generate digests for assets URLs
  21 + config.assets.digest = true
  22 +
  23 + # Defaults to Rails.root.join("public/assets")
  24 + # config.assets.manifest = YOUR_PATH
  25 +
  26 + # Specifies the header that your server uses for sending files
  27 + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  28 + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
  29 +
  30 + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  31 + # config.force_ssl = true
  32 +
  33 + # See everything in the log (default is :info)
  34 + # config.log_level = :debug
  35 +
  36 + # Use a different logger for distributed setups
  37 + # config.logger = SyslogLogger.new
  38 +
  39 + # Use a different cache store in production
  40 + # config.cache_store = :mem_cache_store
  41 +
  42 + # Enable serving of images, stylesheets, and JavaScripts from an asset server
  43 + # config.action_controller.asset_host = "http://assets.example.com"
  44 +
  45 + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  46 + # config.assets.precompile += %w( search.js )
  47 +
  48 + # Disable delivery errors, bad email addresses will be ignored
  49 + # config.action_mailer.raise_delivery_errors = false
  50 +
  51 + # Enable threaded mode
  52 + # config.threadsafe!
  53 +
  54 + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  55 + # the I18n.default_locale when a translation can not be found)
  56 + config.i18n.fallbacks = true
  57 +
  58 + # Send deprecation notices to registered listeners
  59 + config.active_support.deprecation = :notify
  60 +end
42 store-after/config/environments/test.rb
... ... @@ -0,0 +1,42 @@
  1 +Store::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # The test environment is used exclusively to run your application's
  5 + # test suite. You never need to work with it otherwise. Remember that
  6 + # your test database is "scratch space" for the test suite and is wiped
  7 + # and recreated between test runs. Don't rely on the data there!
  8 + config.cache_classes = true
  9 +
  10 + # Configure static asset server for tests with Cache-Control for performance
  11 + config.serve_static_assets = true
  12 + config.static_cache_control = "public, max-age=3600"
  13 +
  14 + # Log error messages when you accidentally call methods on nil
  15 + config.whiny_nils = true
  16 +
  17 + # Show full error reports and disable caching
  18 + config.consider_all_requests_local = true
  19 + config.action_controller.perform_caching = false
  20 +
  21 + # Raise exceptions instead of rendering exception templates
  22 + config.action_dispatch.show_exceptions = false
  23 +
  24 + # Disable request forgery protection in test environment
  25 + config.action_controller.allow_forgery_protection = false
  26 +
  27 + # Tell Action Mailer not to deliver emails to the real world.
  28 + # The :test delivery method accumulates sent emails in the
  29 + # ActionMailer::Base.deliveries array.
  30 + config.action_mailer.delivery_method = :test
  31 +
  32 + # Use SQL instead of Active Record's schema dumper when creating the test database.
  33 + # This is necessary if your schema can't be completely dumped by the schema dumper,
  34 + # like if you have constraints or database-specific column types
  35 + # config.active_record.schema_format = :sql
  36 +
  37 + # Print deprecation notices to the stderr
  38 + config.active_support.deprecation = :stderr
  39 +
  40 + # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
  41 + config.assets.allow_debugging = true
  42 +end
7 store-after/config/initializers/backtrace_silencers.rb
... ... @@ -0,0 +1,7 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  4 +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
  5 +
  6 +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
  7 +# Rails.backtrace_cleaner.remove_silencers!
10 store-after/config/initializers/inflections.rb
... ... @@ -0,0 +1,10 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Add new inflection rules using the following format
  4 +# (all these examples are active by default):
  5 +# ActiveSupport::Inflector.inflections do |inflect|
  6 +# inflect.plural /^(ox)$/i, '\1en'
  7 +# inflect.singular /^(ox)en/i, '\1'
  8 +# inflect.irregular 'person', 'people'
  9 +# inflect.uncountable %w( fish sheep )
  10 +# end
5 store-after/config/initializers/mime_types.rb
... ... @@ -0,0 +1,5 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Add new mime types for use in respond_to blocks:
  4 +# Mime::Type.register "text/richtext", :rtf
  5 +# Mime::Type.register_alias "text/html", :iphone
7 store-after/config/initializers/secret_token.rb
... ... @@ -0,0 +1,7 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Your secret key for verifying the integrity of signed cookies.
  4 +# If you change this key, all old signed cookies will become invalid!
  5 +# Make sure the secret is at least 30 characters and all random,
  6 +# no regular words or you'll be exposed to dictionary attacks.
  7 +Store::Application.config.secret_token = 'ded94729d57cfed50900e137075ac9916071fdf1fdc4fd28dfd56bff5a9911766ced98262ebd3ee116e0848775d4455bb6e98edbb7a7fbd615ba51a1860989d5'
8 store-after/config/initializers/session_store.rb
... ... @@ -0,0 +1,8 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +Store::Application.config.session_store :cookie_store, key: '_store_session'
  4 +
  5 +# Use the database for sessions instead of the cookie-based default,
  6 +# which shouldn't be used to store highly confidential information
  7 +# (create the session table with "rails generate session_migration")
  8 +# Store::Application.config.session_store :active_record_store
14 store-after/config/initializers/wrap_parameters.rb
... ... @@ -0,0 +1,14 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +#
  3 +# This file contains settings for ActionController::ParamsWrapper which
  4 +# is enabled by default.
  5 +
  6 +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
  7 +ActiveSupport.on_load(:action_controller) do
  8 + wrap_parameters format: [:json]
  9 +end
  10 +
  11 +# Disable root element in JSON by default.
  12 +ActiveSupport.on_load(:active_record) do
  13 + self.include_root_in_json = false
  14 +end
5 store-after/config/locales/en.yml
... ... @@ -0,0 +1,5 @@
  1 +# Sample localization file for English. Add more files in this directory for other locales.
  2 +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
  3 +
  4 +en:
  5 + hello: "Hello world"
4 store-after/config/routes.rb
... ... @@ -0,0 +1,4 @@
  1 +Store::Application.routes.draw do
  2 + root to: 'products#index'
  3 + resources :products
  4 +end
11 store-after/db/migrate/20111005175852_create_products.rb
... ... @@ -0,0 +1,11 @@
  1 +class CreateProducts < ActiveRecord::Migration
  2 + def change
  3 + create_table :products do |t|
  4 + t.string :name
  5 + t.decimal :price
  6 + t.datetime :released_at
  7 +
  8 + t.timestamps
  9 + end
  10 + end
  11 +end
24 store-after/db/schema.rb
... ... @@ -0,0 +1,24 @@
  1 +# encoding: UTF-8
  2 +# This file is auto-generated from the current state of the database. Instead
  3 +# of editing this file, please use the migrations feature of Active Record to
  4 +# incrementally modify your database, and then regenerate this schema definition.
  5 +#
  6 +# Note that this schema.rb definition is the authoritative source for your
  7 +# database schema. If you need to create the application database on another
  8 +# system, you should be using db:schema:load, not running all the migrations
  9 +# from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10 +# you'll amass, the slower it'll run and the greater likelihood for issues).
  11 +#
  12 +# It's strongly recommended to check this file into your version control system.
  13 +
  14 +ActiveRecord::Schema.define(:version => 20111005175852) do
  15 +
  16 + create_table "products", :force => true do |t|
  17 + t.string "name"
  18 + t.decimal "price"
  19 + t.datetime "released_at"
  20 + t.datetime "created_at"
  21 + t.datetime "updated_at"
  22 + end
  23 +
  24 +end
34 store-after/db/seeds.rb
... ... @@ -0,0 +1,34 @@
  1 +Product.create!(name: "Settlers of Catan", price: 29.95, released_at: "2011-07-15")
  2 +Product.create!(name: "DVD Player", price: 79.99, released_at: "2011-07-18")
  3 +Product.create!(name: "Red Shirt", price: 12.49, released_at: "2011-07-25")
  4 +Product.create!(name: "Black Leather Couch", price: 399.99, released_at: "2011-07-27")
  5 +Product.create!(name: "Oak Coffee Table", price: 223.99, released_at: "2011-07-28")
  6 +Product.create!(name: "Technodrome", price: 27.99, released_at: "2011-07-28")
  7 +Product.create!(name: "Oh's Cereal", price: 3.95, released_at: "2011-07-29")
  8 +Product.create!(name: "Game Console", price: 299.95, released_at: "2011-08-02")
  9 +Product.create!(name: "Video Game", price: 29.95, released_at: "2011-08-05")
  10 +Product.create!(name: "Lawn Chair", price: 34.99, released_at: "2011-08-05")
  11 +Product.create!(name: "RailsCasts Pro Subscription", price: 9.00, released_at: "2011-10-03")
  12 +Product.create!(name: "Dog Toy Bone", price: 2.99, released_at: "2011-08-08")
  13 +Product.create!(name: "Heated Blanket", price: 27.95, released_at: "2011-08-09")
  14 +Product.create!(name: "Flux Capacitor", price: 19.55, released_at: "2011-08-12")
  15 +Product.create!(name: "Plutonium", price: 2397.25, released_at: "2011-08-18")
  16 +Product.create!(name: "Chocolate Pie", price: 3.14, released_at: "2011-03-14")
  17 +Product.create!(name: "Ryan's Cheesecake", price: 49.99, released_at: "2011-08-22")
  18 +Product.create!(name: "Acoustic Guitar", price: 1025.00, released_at: "2011-08-23")
  19 +Product.create!(name: "Model Enterprise", price: 27.99, released_at: "2011-08-27")
  20 +Product.create!(name: "Agricola", price: 45.99, released_at: "2011-08-28")
  21 +Product.create!(name: "Stone Age", price: 34.99, released_at: "2011-08-30")
  22 +Product.create!(name: "7 Wonders", price: 28.75, released_at: "2011-09-03")
  23 +Product.create!(name: "Millennium Falcon", price: 3597281000.00, released_at: "2011-09-07")
  24 +Product.create!(name: "Answer to Everything", price: 42.00, released_at: "2011-09-08")
  25 +Product.create!(name: "Box Kite", price: 63.00, released_at: "2011-09-10")
  26 +Product.create!(name: "Phil's Painting", price: 399.00, released_at: "2011-09-14")
  27 +Product.create!(name: "1000 Piece Jigsaw Puzzle", price: 14.99, released_at: "2011-09-17")
  28 +Product.create!(name: "TextMate 2", price: 75.00, released_at: "2011-09-22")
  29 +Product.create!(name: "Bowling Ball", price: 127.00, released_at: "2011-09-23")
  30 +Product.create!(name: "Rubber Ducky", price: 4.75, released_at: "2011-09-25")
  31 +Product.create!(name: "Unicorn Action Figure", price: 8.75, released_at: "2011-09-25")
  32 +Product.create!(name: "Rack", price: 32.49, released_at: "2011-09-28")
  33 +Product.create!(name: "Model Train Rails", price: 45.00, released_at: "2011-10-01")
  34 +Product.create!(name: "CanCan Music Record", price: 2.99, released_at: "2011-10-04")
2  store-after/doc/README_FOR_APP
... ... @@ -0,0 +1,2 @@
  1 +Use this README file to introduce your application and point to useful places in the API for learning more.
  2 +Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0  store-after/lib/assets/.gitkeep
No changes.
0  store-after/lib/tasks/.gitkeep
No changes.
0  store-after/log/.gitkeep
No changes.
26 store-after/public/404.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>The page you were looking for doesn't exist (404)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/404.html -->
  21 + <div class="dialog">
  22 + <h1>The page you were looking for doesn't exist.</h1>
  23 + <p>You may have mistyped the address or the page may have moved.</p>
  24 + </div>
  25 +</body>
  26 +</html>
26 store-after/public/422.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>The change you wanted was rejected (422)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/422.html -->
  21 + <div class="dialog">
  22 + <h1>The change you wanted was rejected.</h1>
  23 + <p>Maybe you tried to change something you didn't have access to.</p>
  24 + </div>
  25 +</body>
  26 +</html>
26 store-after/public/500.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>We're sorry, but something went wrong (500)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/500.html -->
  21 + <div class="dialog">
  22 + <h1>We're sorry, but something went wrong.</h1>
  23 + <p>We've been notified about this issue and we'll take a look at it shortly.</p>
  24 + </div>
  25 +</body>
  26 +</html>
0  store-after/public/favicon.ico
No changes.
5 store-after/public/robots.txt
... ... @@ -0,0 +1,5 @@
  1 +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
  2 +#
  3 +# To ban all spiders from the entire site uncomment the next two lines:
  4 +# User-Agent: *
  5 +# Disallow: /
6 store-after/script/rails
... ... @@ -0,0 +1,6 @@
  1 +#!/usr/bin/env ruby
  2 +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
  3 +
  4 +APP_PATH = File.expand_path('../../config/application', __FILE__)
  5 +require File.expand_path('../../config/boot', __FILE__)
  6 +require 'rails/commands'
0  store-after/test/fixtures/.gitkeep
No changes.
0  store-after/test/functional/.gitkeep
No changes.
49 store-after/test/functional/products_controller_test.rb
... ... @@ -0,0 +1,49 @@
  1 +require 'test_helper'
  2 +
  3 +class ProductsControllerTest < ActionController::TestCase
  4 + setup do
  5 + @product = products(:one)
  6 + end
  7 +
  8 + test "should get index" do
  9 + get :index
  10 + assert_response :success
  11 + assert_not_nil assigns(:products)
  12 + end
  13 +
  14 + test "should get new" do
  15 + get :new
  16 + assert_response :success
  17 + end
  18 +
  19 + test "should create product" do
  20 + assert_difference('Product.count') do
  21 + post :create, product: @product.attributes
  22 + end
  23 +
  24 + assert_redirected_to product_path(assigns(:product))
  25 + end
  26 +
  27 + test "should show product" do
  28 + get :show, id: @product.to_param
  29 + assert_response :success
  30 + end
  31 +
  32 + test "should get edit" do
  33 + get :edit, id: @product.to_param
  34 + assert_response :success
  35 + end
  36 +
  37 + test "should update product" do
  38 + put :update, id: @product.to_param, product: @product.attributes
  39 + assert_redirected_to product_path(assigns(:product))
  40 + end
  41 +
  42 + test "should destroy product" do
  43 + assert_difference('Product.count', -1) do
  44 + delete :destroy, id: @product.to_param
  45 + end
  46 +
  47 + assert_redirected_to products_path