Permalink
Browse files

adding revised episode 88

  • Loading branch information...
1 parent 365744f commit 2e734552008c66a6602742729868893c812fa883 @ryanb committed Nov 26, 2011
Showing with 5,524 additions and 0 deletions.
  1. +5 −0 episode-088/README
  2. +15 −0 episode-088/store-after/.gitignore
  3. +36 −0 episode-088/store-after/Gemfile
  4. +118 −0 episode-088/store-after/Gemfile.lock
  5. +9 −0 episode-088/store-after/README
  6. +7 −0 episode-088/store-after/Rakefile
  7. BIN episode-088/store-after/app/assets/images/rails.png
  8. +9 −0 episode-088/store-after/app/assets/javascripts/application.js
  9. +16 −0 episode-088/store-after/app/assets/javascripts/people.js.coffee
  10. +87 −0 episode-088/store-after/app/assets/stylesheets/application.css
  11. +3 −0 episode-088/store-after/app/assets/stylesheets/people.css.scss
  12. +3 −0 episode-088/store-after/app/controllers/application_controller.rb
  13. +5 −0 episode-088/store-after/app/controllers/people_controller.rb
  14. +2 −0 episode-088/store-after/app/helpers/application_helper.rb
  15. +2 −0 episode-088/store-after/app/helpers/people_helper.rb
  16. 0 episode-088/store-after/app/mailers/.gitkeep
  17. 0 episode-088/store-after/app/models/.gitkeep
  18. +4 −0 episode-088/store-after/app/models/country.rb
  19. +4 −0 episode-088/store-after/app/models/person.rb
  20. +4 −0 episode-088/store-after/app/models/state.rb
  21. +17 −0 episode-088/store-after/app/views/layouts/application.html.erb
  22. +17 −0 episode-088/store-after/app/views/people/new.html.erb
  23. +4 −0 episode-088/store-after/config.ru
  24. +48 −0 episode-088/store-after/config/application.rb
  25. +6 −0 episode-088/store-after/config/boot.rb
  26. +25 −0 episode-088/store-after/config/database.yml
  27. +5 −0 episode-088/store-after/config/environment.rb
  28. +30 −0 episode-088/store-after/config/environments/development.rb
  29. +60 −0 episode-088/store-after/config/environments/production.rb
  30. +39 −0 episode-088/store-after/config/environments/test.rb
  31. +7 −0 episode-088/store-after/config/initializers/backtrace_silencers.rb
  32. +10 −0 episode-088/store-after/config/initializers/inflections.rb
  33. +5 −0 episode-088/store-after/config/initializers/mime_types.rb
  34. +7 −0 episode-088/store-after/config/initializers/secret_token.rb
  35. +8 −0 episode-088/store-after/config/initializers/session_store.rb
  36. +14 −0 episode-088/store-after/config/initializers/wrap_parameters.rb
  37. +5 −0 episode-088/store-after/config/locales/en.yml
  38. +4 −0 episode-088/store-after/config/routes.rb
  39. +246 −0 episode-088/store-after/countries.csv
  40. +11 −0 episode-088/store-after/db/migrate/20111125194923_create_people.rb
  41. +9 −0 episode-088/store-after/db/migrate/20111125195329_create_countries.rb
  42. +10 −0 episode-088/store-after/db/migrate/20111125195340_create_states.rb
  43. +37 −0 episode-088/store-after/db/schema.rb
  44. +17 −0 episode-088/store-after/db/seeds.rb
  45. +2 −0 episode-088/store-after/doc/README_FOR_APP
  46. 0 episode-088/store-after/lib/assets/.gitkeep
  47. 0 episode-088/store-after/lib/tasks/.gitkeep
  48. 0 episode-088/store-after/log/.gitkeep
  49. +26 −0 episode-088/store-after/public/404.html
  50. +26 −0 episode-088/store-after/public/422.html
  51. +26 −0 episode-088/store-after/public/500.html
  52. 0 episode-088/store-after/public/favicon.ico
  53. +5 −0 episode-088/store-after/public/robots.txt
  54. +6 −0 episode-088/store-after/script/rails
  55. +1,626 −0 episode-088/store-after/states.csv
  56. 0 episode-088/store-after/test/fixtures/.gitkeep
  57. +7 −0 episode-088/store-after/test/fixtures/countries.yml
  58. +11 −0 episode-088/store-after/test/fixtures/people.yml
  59. +9 −0 episode-088/store-after/test/fixtures/states.yml
  60. 0 episode-088/store-after/test/functional/.gitkeep
  61. +7 −0 episode-088/store-after/test/functional/people_controller_test.rb
  62. 0 episode-088/store-after/test/integration/.gitkeep
  63. +12 −0 episode-088/store-after/test/performance/browsing_test.rb
  64. +13 −0 episode-088/store-after/test/test_helper.rb
  65. 0 episode-088/store-after/test/unit/.gitkeep
  66. +7 −0 episode-088/store-after/test/unit/country_test.rb
  67. +4 −0 episode-088/store-after/test/unit/helpers/people_helper_test.rb
  68. +7 −0 episode-088/store-after/test/unit/person_test.rb
  69. +7 −0 episode-088/store-after/test/unit/state_test.rb
  70. 0 episode-088/store-after/vendor/assets/stylesheets/.gitkeep
  71. 0 episode-088/store-after/vendor/plugins/.gitkeep
  72. +15 −0 episode-088/store-before/.gitignore
  73. +36 −0 episode-088/store-before/Gemfile
  74. +118 −0 episode-088/store-before/Gemfile.lock
  75. +9 −0 episode-088/store-before/README
  76. +7 −0 episode-088/store-before/Rakefile
  77. BIN episode-088/store-before/app/assets/images/rails.png
  78. +9 −0 episode-088/store-before/app/assets/javascripts/application.js
  79. +3 −0 episode-088/store-before/app/assets/javascripts/people.js.coffee
  80. +87 −0 episode-088/store-before/app/assets/stylesheets/application.css
  81. +3 −0 episode-088/store-before/app/assets/stylesheets/people.css.scss
  82. +3 −0 episode-088/store-before/app/controllers/application_controller.rb
  83. +5 −0 episode-088/store-before/app/controllers/people_controller.rb
  84. +2 −0 episode-088/store-before/app/helpers/application_helper.rb
  85. +2 −0 episode-088/store-before/app/helpers/people_helper.rb
  86. 0 episode-088/store-before/app/mailers/.gitkeep
  87. 0 episode-088/store-before/app/models/.gitkeep
  88. +4 −0 episode-088/store-before/app/models/country.rb
  89. +4 −0 episode-088/store-before/app/models/person.rb
  90. +4 −0 episode-088/store-before/app/models/state.rb
  91. +17 −0 episode-088/store-before/app/views/layouts/application.html.erb
  92. +17 −0 episode-088/store-before/app/views/people/new.html.erb
  93. +4 −0 episode-088/store-before/config.ru
  94. +48 −0 episode-088/store-before/config/application.rb
  95. +6 −0 episode-088/store-before/config/boot.rb
  96. +25 −0 episode-088/store-before/config/database.yml
  97. +5 −0 episode-088/store-before/config/environment.rb
  98. +30 −0 episode-088/store-before/config/environments/development.rb
  99. +60 −0 episode-088/store-before/config/environments/production.rb
  100. +39 −0 episode-088/store-before/config/environments/test.rb
  101. +7 −0 episode-088/store-before/config/initializers/backtrace_silencers.rb
  102. +10 −0 episode-088/store-before/config/initializers/inflections.rb
  103. +5 −0 episode-088/store-before/config/initializers/mime_types.rb
  104. +7 −0 episode-088/store-before/config/initializers/secret_token.rb
  105. +8 −0 episode-088/store-before/config/initializers/session_store.rb
  106. +14 −0 episode-088/store-before/config/initializers/wrap_parameters.rb
  107. +5 −0 episode-088/store-before/config/locales/en.yml
  108. +4 −0 episode-088/store-before/config/routes.rb
  109. +246 −0 episode-088/store-before/countries.csv
  110. +11 −0 episode-088/store-before/db/migrate/20111125194923_create_people.rb
  111. +9 −0 episode-088/store-before/db/migrate/20111125195329_create_countries.rb
  112. +10 −0 episode-088/store-before/db/migrate/20111125195340_create_states.rb
  113. +37 −0 episode-088/store-before/db/schema.rb
  114. +17 −0 episode-088/store-before/db/seeds.rb
  115. +2 −0 episode-088/store-before/doc/README_FOR_APP
  116. 0 episode-088/store-before/lib/assets/.gitkeep
  117. 0 episode-088/store-before/lib/tasks/.gitkeep
  118. 0 episode-088/store-before/log/.gitkeep
  119. +26 −0 episode-088/store-before/public/404.html
  120. +26 −0 episode-088/store-before/public/422.html
  121. +26 −0 episode-088/store-before/public/500.html
  122. 0 episode-088/store-before/public/favicon.ico
  123. +5 −0 episode-088/store-before/public/robots.txt
  124. +6 −0 episode-088/store-before/script/rails
  125. +1,626 −0 episode-088/store-before/states.csv
  126. 0 episode-088/store-before/test/fixtures/.gitkeep
  127. +7 −0 episode-088/store-before/test/fixtures/countries.yml
  128. +11 −0 episode-088/store-before/test/fixtures/people.yml
  129. +9 −0 episode-088/store-before/test/fixtures/states.yml
  130. 0 episode-088/store-before/test/functional/.gitkeep
  131. +7 −0 episode-088/store-before/test/functional/people_controller_test.rb
  132. 0 episode-088/store-before/test/integration/.gitkeep
  133. +12 −0 episode-088/store-before/test/performance/browsing_test.rb
  134. +13 −0 episode-088/store-before/test/test_helper.rb
  135. 0 episode-088/store-before/test/unit/.gitkeep
  136. +7 −0 episode-088/store-before/test/unit/country_test.rb
  137. +4 −0 episode-088/store-before/test/unit/helpers/people_helper_test.rb
  138. +7 −0 episode-088/store-before/test/unit/person_test.rb
  139. +7 −0 episode-088/store-before/test/unit/state_test.rb
  140. 0 episode-088/store-before/vendor/assets/stylesheets/.gitkeep
  141. 0 episode-088/store-before/vendor/plugins/.gitkeep
View
@@ -0,0 +1,5 @@
+RailsCasts Episode #88: Dynamic Select Menus (revised)
+
+http://railscasts.com/episodes/88-dynamic-select-menus-revised
+
+Require Ruby 1.9.2 or higher to run examples.
@@ -0,0 +1,15 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+
+# Ignore all logfiles and tempfiles.
+/log/*.log
+/tmp
@@ -0,0 +1,36 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.3'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.5'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+# To use ActiveModel has_secure_password
+# gem 'bcrypt-ruby', '~> 3.0.0'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
+
+group :test do
+ # Pretty printed test output
+ gem 'turn', '~> 0.8.3', :require => false
+end
@@ -0,0 +1,118 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ ansi (1.4.1)
+ arel (2.2.1)
+ builder (3.0.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.3)
+ erubis (2.7.0)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.18)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.1)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.3)
+ polyglot (0.3.3)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.11)
+ json (~> 1.4)
+ sass (3.1.10)
+ sass-rails (3.1.5)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (~> 3.1.10)
+ tilt (~> 1.3.2)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ turn (0.8.3)
+ ansi
+ tzinfo (0.3.31)
+ uglifier (1.1.0)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.1)
+ jquery-rails
+ rails (= 3.1.3)
+ sass-rails (~> 3.1.5)
+ sqlite3
+ turn (~> 0.8.3)
+ uglifier (>= 1.0.3)
@@ -0,0 +1,9 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
+
+Requires Ruby 1.9.2 or later to run.
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Store::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -0,0 +1,16 @@
+# 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://jashkenas.github.com/coffee-script/
+jQuery ->
+ $('#person_state_id').parent().hide()
+ states = $('#person_state_id').html()
+ $('#person_country_id').change ->
+ country = $('#person_country_id :selected').text()
+ escaped_country = country.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
+ options = $(states).filter("optgroup[label='#{escaped_country}']").html()
+ if options
+ $('#person_state_id').html(options)
+ $('#person_state_id').parent().show()
+ else
+ $('#person_state_id').empty()
+ $('#person_state_id').parent().hide()
@@ -0,0 +1,87 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
+
+body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 75%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+.field_with_errors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+.error_messages h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+.error_messages p {
+ margin: 8px 10px;
+}
+
+.error_messages ul {
+ margin-bottom: 0;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
@@ -0,0 +1,3 @@
+// Place all the styles related to the people controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,5 @@
+class PeopleController < ApplicationController
+ def new
+ @person = Person.new
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module PeopleHelper
+end
@@ -0,0 +1,4 @@
+class Country < ActiveRecord::Base
+ has_many :states
+ has_many :people
+end
@@ -0,0 +1,4 @@
+class Person < ActiveRecord::Base
+ belongs_to :country
+ belongs_to :state
+end
@@ -0,0 +1,4 @@
+class State < ActiveRecord::Base
+ belongs_to :country
+ has_many :people
+end
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Blog</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tag %>
+ </head>
+ <body>
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,17 @@
+<h1>New Person</h1>
+
+<%= form_for @person do |f| %>
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :country_id %><br />
+ <%= f.collection_select :country_id, Country.order(:name), :id, :name, include_blank: true %>
+ </div>
+ <div class="field">
+ <%= f.label :state_id, "State or Province" %><br />
+ <%= f.grouped_collection_select :state_id, Country.order(:name), :states, :name, :id, :name, include_blank: true %>
+ </div>
+ <div class="actions"><%= f.submit %></div>
+<% end %>
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Store::Application
Oops, something went wrong.

0 comments on commit 2e73455

Please sign in to comment.