Permalink
Browse files

adding revised episode 90

  • Loading branch information...
1 parent 34da21a commit 1edc1f7b799fbd2ccac3ebaa3626024fc02f2141 @ryanb committed Feb 19, 2012
Showing with 2,275 additions and 0 deletions.
  1. +15 −0 episode-090/README.md
  2. +15 −0 episode-090/blog-after/.gitignore
  3. +38 −0 episode-090/blog-after/Gemfile
  4. +111 −0 episode-090/blog-after/Gemfile.lock
  5. +9 −0 episode-090/blog-after/README.rdoc
  6. +7 −0 episode-090/blog-after/Rakefile
  7. BIN episode-090/blog-after/app/assets/images/rails.png
  8. +15 −0 episode-090/blog-after/app/assets/javascripts/application.js
  9. +3 −0 episode-090/blog-after/app/assets/javascripts/articles.js.coffee
  10. +3 −0 episode-090/blog-after/app/assets/javascripts/comments.js.coffee
  11. +126 −0 episode-090/blog-after/app/assets/stylesheets/application.css
  12. +24 −0 episode-090/blog-after/app/assets/stylesheets/articles.css.scss
  13. +3 −0 episode-090/blog-after/app/assets/stylesheets/comments.css.scss
  14. +12 −0 episode-090/blog-after/app/controllers/application_controller.rb
  15. +25 −0 episode-090/blog-after/app/controllers/articles_controller.rb
  16. +14 −0 episode-090/blog-after/app/controllers/comments_controller.rb
  17. +2 −0 episode-090/blog-after/app/helpers/application_helper.rb
  18. +2 −0 episode-090/blog-after/app/helpers/articles_helper.rb
  19. +2 −0 episode-090/blog-after/app/helpers/comments_helper.rb
  20. 0 episode-090/blog-after/app/mailers/.gitkeep
  21. 0 episode-090/blog-after/app/models/.gitkeep
  22. +3 −0 episode-090/blog-after/app/models/article.rb
  23. +3 −0 episode-090/blog-after/app/models/comment.rb
  24. +28 −0 episode-090/blog-after/app/views/articles/edit.html.erb
  25. +15 −0 episode-090/blog-after/app/views/articles/index.html.erb
  26. +29 −0 episode-090/blog-after/app/views/articles/show.html.erb
  27. +5 −0 episode-090/blog-after/app/views/comments/_comment.html.erb
  28. +23 −0 episode-090/blog-after/app/views/comments/_form.html.erb
  29. +3 −0 episode-090/blog-after/app/views/comments/new.html.erb
  30. +17 −0 episode-090/blog-after/app/views/layouts/application.html.erb
  31. +4 −0 episode-090/blog-after/config.ru
  32. +59 −0 episode-090/blog-after/config/application.rb
  33. +6 −0 episode-090/blog-after/config/boot.rb
  34. +25 −0 episode-090/blog-after/config/database.yml
  35. +5 −0 episode-090/blog-after/config/environment.rb
  36. +37 −0 episode-090/blog-after/config/environments/development.rb
  37. +67 −0 episode-090/blog-after/config/environments/production.rb
  38. +37 −0 episode-090/blog-after/config/environments/test.rb
  39. +7 −0 episode-090/blog-after/config/initializers/backtrace_silencers.rb
  40. +15 −0 episode-090/blog-after/config/initializers/inflections.rb
  41. +5 −0 episode-090/blog-after/config/initializers/mime_types.rb
  42. +7 −0 episode-090/blog-after/config/initializers/secret_token.rb
  43. +8 −0 episode-090/blog-after/config/initializers/session_store.rb
  44. +14 −0 episode-090/blog-after/config/initializers/wrap_parameters.rb
  45. +5 −0 episode-090/blog-after/config/locales/en.yml
  46. +5 −0 episode-090/blog-after/config/routes.rb
  47. +12 −0 episode-090/blog-after/db/migrate/20120130184408_create_articles.rb
  48. +12 −0 episode-090/blog-after/db/migrate/20120130184732_create_comments.rb
  49. +35 −0 episode-090/blog-after/db/schema.rb
  50. +14 −0 episode-090/blog-after/db/seeds.rb
  51. +2 −0 episode-090/blog-after/doc/README_FOR_APP
  52. 0 episode-090/blog-after/lib/assets/.gitkeep
  53. 0 episode-090/blog-after/lib/tasks/.gitkeep
  54. 0 episode-090/blog-after/log/.gitkeep
  55. +26 −0 episode-090/blog-after/public/404.html
  56. +26 −0 episode-090/blog-after/public/422.html
  57. +25 −0 episode-090/blog-after/public/500.html
  58. 0 episode-090/blog-after/public/favicon.ico
  59. +5 −0 episode-090/blog-after/public/robots.txt
  60. +6 −0 episode-090/blog-after/script/rails
  61. 0 episode-090/blog-after/test/fixtures/.gitkeep
  62. +11 −0 episode-090/blog-after/test/fixtures/articles.yml
  63. +11 −0 episode-090/blog-after/test/fixtures/comments.yml
  64. 0 episode-090/blog-after/test/functional/.gitkeep
  65. +49 −0 episode-090/blog-after/test/functional/articles_controller_test.rb
  66. +9 −0 episode-090/blog-after/test/functional/comments_controller_test.rb
  67. 0 episode-090/blog-after/test/integration/.gitkeep
  68. +12 −0 episode-090/blog-after/test/performance/browsing_test.rb
  69. +13 −0 episode-090/blog-after/test/test_helper.rb
  70. 0 episode-090/blog-after/test/unit/.gitkeep
  71. +7 −0 episode-090/blog-after/test/unit/article_test.rb
  72. +7 −0 episode-090/blog-after/test/unit/comment_test.rb
  73. +4 −0 episode-090/blog-after/test/unit/helpers/articles_helper_test.rb
  74. +4 −0 episode-090/blog-after/test/unit/helpers/comments_helper_test.rb
  75. 0 episode-090/blog-after/vendor/assets/javascripts/.gitkeep
  76. 0 episode-090/blog-after/vendor/assets/stylesheets/.gitkeep
  77. 0 episode-090/blog-after/vendor/plugins/.gitkeep
  78. +15 −0 episode-090/blog-before/.gitignore
  79. +38 −0 episode-090/blog-before/Gemfile
  80. +111 −0 episode-090/blog-before/Gemfile.lock
  81. +9 −0 episode-090/blog-before/README.rdoc
  82. +7 −0 episode-090/blog-before/Rakefile
  83. BIN episode-090/blog-before/app/assets/images/rails.png
  84. +15 −0 episode-090/blog-before/app/assets/javascripts/application.js
  85. +3 −0 episode-090/blog-before/app/assets/javascripts/articles.js.coffee
  86. +3 −0 episode-090/blog-before/app/assets/javascripts/comments.js.coffee
  87. +126 −0 episode-090/blog-before/app/assets/stylesheets/application.css
  88. +24 −0 episode-090/blog-before/app/assets/stylesheets/articles.css.scss
  89. +3 −0 episode-090/blog-before/app/assets/stylesheets/comments.css.scss
  90. +12 −0 episode-090/blog-before/app/controllers/application_controller.rb
  91. +24 −0 episode-090/blog-before/app/controllers/articles_controller.rb
  92. +14 −0 episode-090/blog-before/app/controllers/comments_controller.rb
  93. +2 −0 episode-090/blog-before/app/helpers/application_helper.rb
  94. +2 −0 episode-090/blog-before/app/helpers/articles_helper.rb
  95. +2 −0 episode-090/blog-before/app/helpers/comments_helper.rb
  96. 0 episode-090/blog-before/app/mailers/.gitkeep
  97. 0 episode-090/blog-before/app/models/.gitkeep
  98. +3 −0 episode-090/blog-before/app/models/article.rb
  99. +3 −0 episode-090/blog-before/app/models/comment.rb
  100. +29 −0 episode-090/blog-before/app/views/articles/edit.html.erb
  101. +15 −0 episode-090/blog-before/app/views/articles/index.html.erb
  102. +23 −0 episode-090/blog-before/app/views/articles/show.html.erb
  103. +5 −0 episode-090/blog-before/app/views/comments/_comment.html.erb
  104. +23 −0 episode-090/blog-before/app/views/comments/_form.html.erb
  105. +3 −0 episode-090/blog-before/app/views/comments/new.html.erb
  106. +17 −0 episode-090/blog-before/app/views/layouts/application.html.erb
  107. +4 −0 episode-090/blog-before/config.ru
  108. +59 −0 episode-090/blog-before/config/application.rb
  109. +6 −0 episode-090/blog-before/config/boot.rb
  110. +25 −0 episode-090/blog-before/config/database.yml
  111. +5 −0 episode-090/blog-before/config/environment.rb
  112. +37 −0 episode-090/blog-before/config/environments/development.rb
  113. +67 −0 episode-090/blog-before/config/environments/production.rb
  114. +37 −0 episode-090/blog-before/config/environments/test.rb
  115. +7 −0 episode-090/blog-before/config/initializers/backtrace_silencers.rb
  116. +15 −0 episode-090/blog-before/config/initializers/inflections.rb
  117. +5 −0 episode-090/blog-before/config/initializers/mime_types.rb
  118. +7 −0 episode-090/blog-before/config/initializers/secret_token.rb
  119. +8 −0 episode-090/blog-before/config/initializers/session_store.rb
  120. +14 −0 episode-090/blog-before/config/initializers/wrap_parameters.rb
  121. +5 −0 episode-090/blog-before/config/locales/en.yml
  122. +5 −0 episode-090/blog-before/config/routes.rb
  123. +12 −0 episode-090/blog-before/db/migrate/20120130184408_create_articles.rb
  124. +12 −0 episode-090/blog-before/db/migrate/20120130184732_create_comments.rb
  125. +35 −0 episode-090/blog-before/db/schema.rb
  126. +14 −0 episode-090/blog-before/db/seeds.rb
  127. +2 −0 episode-090/blog-before/doc/README_FOR_APP
  128. 0 episode-090/blog-before/lib/assets/.gitkeep
  129. 0 episode-090/blog-before/lib/tasks/.gitkeep
  130. 0 episode-090/blog-before/log/.gitkeep
  131. +26 −0 episode-090/blog-before/public/404.html
  132. +26 −0 episode-090/blog-before/public/422.html
  133. +25 −0 episode-090/blog-before/public/500.html
  134. 0 episode-090/blog-before/public/favicon.ico
  135. +5 −0 episode-090/blog-before/public/robots.txt
  136. +6 −0 episode-090/blog-before/script/rails
  137. 0 episode-090/blog-before/test/fixtures/.gitkeep
  138. +11 −0 episode-090/blog-before/test/fixtures/articles.yml
  139. +11 −0 episode-090/blog-before/test/fixtures/comments.yml
  140. 0 episode-090/blog-before/test/functional/.gitkeep
  141. +49 −0 episode-090/blog-before/test/functional/articles_controller_test.rb
  142. +9 −0 episode-090/blog-before/test/functional/comments_controller_test.rb
  143. 0 episode-090/blog-before/test/integration/.gitkeep
  144. +12 −0 episode-090/blog-before/test/performance/browsing_test.rb
  145. +13 −0 episode-090/blog-before/test/test_helper.rb
  146. 0 episode-090/blog-before/test/unit/.gitkeep
  147. +7 −0 episode-090/blog-before/test/unit/article_test.rb
  148. +7 −0 episode-090/blog-before/test/unit/comment_test.rb
  149. +4 −0 episode-090/blog-before/test/unit/helpers/articles_helper_test.rb
  150. +4 −0 episode-090/blog-before/test/unit/helpers/comments_helper_test.rb
  151. 0 episode-090/blog-before/vendor/assets/javascripts/.gitkeep
  152. 0 episode-090/blog-before/vendor/assets/stylesheets/.gitkeep
  153. 0 episode-090/blog-before/vendor/plugins/.gitkeep
View
@@ -0,0 +1,15 @@
+# RailsCasts Episode #90: Fragment Caching (revised)
+
+http://railscasts.com/episodes/90-fragment-caching-revised
+
+Require Ruby 1.9.2 or higher to run examples.
+
+Commands used in rails console
+
+```ruby
+article = Article.first
+article.cache_key
+article.touch
+Rails.cache.read("views/recent_articles")
+Rails.cache.class
+```
@@ -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,38 @@
+source 'https://rubygems.org'
+
+gem 'rails', '3.2.1'
+
+# 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.2.3'
+ gem 'coffee-rails', '~> 3.2.1'
+
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ # gem 'therubyracer'
+
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+# To use ActiveModel has_secure_password
+# gem 'bcrypt-ruby', '~> 3.0.0'
+
+# To use Jbuilder templates for JSON
+# gem 'jbuilder'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
@@ -0,0 +1,111 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actionmailer (3.2.1)
+ actionpack (= 3.2.1)
+ mail (~> 2.4.0)
+ actionpack (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ activerecord (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ arel (~> 3.0.0)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.0)
+ builder (3.0.0)
+ coffee-rails (3.2.2)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.2.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ erubis (2.7.0)
+ execjs (1.3.0)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.1)
+ jquery-rails (2.0.0)
+ railties (>= 3.2.0.beta, < 5.0)
+ thor (~> 0.14)
+ json (1.6.5)
+ mail (2.4.1)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.1)
+ actionmailer (= 3.2.1)
+ actionpack (= 3.2.1)
+ activerecord (= 3.2.1)
+ activeresource (= 3.2.1)
+ activesupport (= 3.2.1)
+ bundler (~> 1.0)
+ railties (= 3.2.1)
+ railties (3.2.1)
+ actionpack (= 3.2.1)
+ activesupport (= 3.2.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sass (3.1.12)
+ sass-rails (3.2.4)
+ railties (~> 3.2.0)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ uglifier (1.2.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.2.1)
+ jquery-rails
+ rails (= 3.2.1)
+ sass-rails (~> 3.2.3)
+ sqlite3
+ 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__)
+
+Blog::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,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -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://jashkenas.github.com/coffee-script/
@@ -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://jashkenas.github.com/coffee-script/
@@ -0,0 +1,126 @@
+/*
+ * 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;
+}
+
+#articles h2 {
+ font-size: 16px;
+ margin-bottom: 2px;
+ margin-top: 20px;
+}
+
+#articles h2 .comments {
+ font-size: 12px;
+ font-weight: normal;
+}
+
+#articles .info {
+ font-style: italic;
+ color: #333;
+ margin-bottom: 8px;
+ font-size: 12px;
+}
+
+#comments {
+ font-size: 12px;
+ background-color: #EEE;
+ padding: 0 20px;
+ width: 325px;
+ border: solid 1px #777;
+}
+
+.comment {
+ border-bottom: solid 1px #999;
+ margin: 15px 0;
+}
+
+.comment:last-child {
+ border-bottom: none;
+}
+
+.comment .author_name {
+ font-weight: bold;
+}
@@ -0,0 +1,24 @@
+// Place all the styles related to the articles controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+#recent_articles {
+ padding: 15px 12px;
+ padding-right: 20px;
+ float: right;
+ margin-left: 20px;
+ margin-bottom: 200px;
+ margin-top: 10px;
+ h3 {
+ font-size: 14px;
+ margin: 0;
+ margin-bottom: 3px;
+ }
+ ul {
+ margin: 0;
+ padding: 0;
+ li {
+ margin: 2px 0;
+ margin-left: 20px;
+ }
+ }
+}
@@ -0,0 +1,3 @@
+// Place all the styles related to the comments controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,12 @@
+require "ostruct"
+
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+
+private
+
+ def current_user
+ OpenStruct.new(admin?: true)
+ end
+ helper_method :current_user
+end
Oops, something went wrong.

0 comments on commit 1edc1f7

Please sign in to comment.