Permalink
Browse files

adding revised episode 250

  • Loading branch information...
1 parent 507cb2b commit 095087e4b9fb8c7c1cb08f510b19454fbd969c88 @ryanb committed Feb 26, 2012
Showing with 2,127 additions and 0 deletions.
  1. +13 −0 episode-250/revised/README.md
  2. +15 −0 episode-250/revised/blog-after/.gitignore
  3. +38 −0 episode-250/revised/blog-after/Gemfile
  4. +113 −0 episode-250/revised/blog-after/Gemfile.lock
  5. +9 −0 episode-250/revised/blog-after/README.rdoc
  6. +7 −0 episode-250/revised/blog-after/Rakefile
  7. BIN episode-250/revised/blog-after/app/assets/images/rails.png
  8. +15 −0 episode-250/revised/blog-after/app/assets/javascripts/application.js
  9. +3 −0 episode-250/revised/blog-after/app/assets/javascripts/articles.js.coffee
  10. +3 −0 episode-250/revised/blog-after/app/assets/javascripts/sessions.js.coffee
  11. +3 −0 episode-250/revised/blog-after/app/assets/javascripts/users.js.coffee
  12. +105 −0 episode-250/revised/blog-after/app/assets/stylesheets/application.css
  13. +24 −0 episode-250/revised/blog-after/app/assets/stylesheets/articles.css.scss
  14. +3 −0 episode-250/revised/blog-after/app/assets/stylesheets/sessions.css.scss
  15. +3 −0 episode-250/revised/blog-after/app/assets/stylesheets/users.css.scss
  16. +14 −0 episode-250/revised/blog-after/app/controllers/application_controller.rb
  17. +24 −0 episode-250/revised/blog-after/app/controllers/articles_controller.rb
  18. +20 −0 episode-250/revised/blog-after/app/controllers/sessions_controller.rb
  19. +15 −0 episode-250/revised/blog-after/app/controllers/users_controller.rb
  20. +2 −0 episode-250/revised/blog-after/app/helpers/application_helper.rb
  21. +2 −0 episode-250/revised/blog-after/app/helpers/articles_helper.rb
  22. +2 −0 episode-250/revised/blog-after/app/helpers/sessions_helper.rb
  23. +2 −0 episode-250/revised/blog-after/app/helpers/users_helper.rb
  24. 0 episode-250/revised/blog-after/app/mailers/.gitkeep
  25. 0 episode-250/revised/blog-after/app/models/.gitkeep
  26. +3 −0 episode-250/revised/blog-after/app/models/article.rb
  27. +7 −0 episode-250/revised/blog-after/app/models/user.rb
  28. +29 −0 episode-250/revised/blog-after/app/views/articles/edit.html.erb
  29. +14 −0 episode-250/revised/blog-after/app/views/articles/index.html.erb
  30. +6 −0 episode-250/revised/blog-after/app/views/articles/show.html.erb
  31. +28 −0 episode-250/revised/blog-after/app/views/layouts/application.html.erb
  32. +13 −0 episode-250/revised/blog-after/app/views/sessions/new.html.erb
  33. +28 −0 episode-250/revised/blog-after/app/views/users/new.html.erb
  34. +4 −0 episode-250/revised/blog-after/config.ru
  35. +59 −0 episode-250/revised/blog-after/config/application.rb
  36. +6 −0 episode-250/revised/blog-after/config/boot.rb
  37. +25 −0 episode-250/revised/blog-after/config/database.yml
  38. +5 −0 episode-250/revised/blog-after/config/environment.rb
  39. +37 −0 episode-250/revised/blog-after/config/environments/development.rb
  40. +67 −0 episode-250/revised/blog-after/config/environments/production.rb
  41. +37 −0 episode-250/revised/blog-after/config/environments/test.rb
  42. +7 −0 episode-250/revised/blog-after/config/initializers/backtrace_silencers.rb
  43. +15 −0 episode-250/revised/blog-after/config/initializers/inflections.rb
  44. +5 −0 episode-250/revised/blog-after/config/initializers/mime_types.rb
  45. +7 −0 episode-250/revised/blog-after/config/initializers/secret_token.rb
  46. +8 −0 episode-250/revised/blog-after/config/initializers/session_store.rb
  47. +14 −0 episode-250/revised/blog-after/config/initializers/wrap_parameters.rb
  48. +5 −0 episode-250/revised/blog-after/config/locales/en.yml
  49. +11 −0 episode-250/revised/blog-after/config/routes.rb
  50. +12 −0 episode-250/revised/blog-after/db/migrate/20120130184408_create_articles.rb
  51. +10 −0 episode-250/revised/blog-after/db/migrate/20120224225432_create_users.rb
  52. +32 −0 episode-250/revised/blog-after/db/schema.rb
  53. +7 −0 episode-250/revised/blog-after/db/seeds.rb
  54. +2 −0 episode-250/revised/blog-after/doc/README_FOR_APP
  55. 0 episode-250/revised/blog-after/lib/assets/.gitkeep
  56. 0 episode-250/revised/blog-after/lib/tasks/.gitkeep
  57. 0 episode-250/revised/blog-after/log/.gitkeep
  58. +26 −0 episode-250/revised/blog-after/public/404.html
  59. +26 −0 episode-250/revised/blog-after/public/422.html
  60. +25 −0 episode-250/revised/blog-after/public/500.html
  61. 0 episode-250/revised/blog-after/public/favicon.ico
  62. +5 −0 episode-250/revised/blog-after/public/robots.txt
  63. +6 −0 episode-250/revised/blog-after/script/rails
  64. 0 episode-250/revised/blog-after/test/fixtures/.gitkeep
  65. +11 −0 episode-250/revised/blog-after/test/fixtures/articles.yml
  66. +9 −0 episode-250/revised/blog-after/test/fixtures/users.yml
  67. 0 episode-250/revised/blog-after/test/functional/.gitkeep
  68. +49 −0 episode-250/revised/blog-after/test/functional/articles_controller_test.rb
  69. +9 −0 episode-250/revised/blog-after/test/functional/sessions_controller_test.rb
  70. +7 −0 episode-250/revised/blog-after/test/functional/users_controller_test.rb
  71. 0 episode-250/revised/blog-after/test/integration/.gitkeep
  72. +12 −0 episode-250/revised/blog-after/test/performance/browsing_test.rb
  73. +13 −0 episode-250/revised/blog-after/test/test_helper.rb
  74. 0 episode-250/revised/blog-after/test/unit/.gitkeep
  75. +7 −0 episode-250/revised/blog-after/test/unit/article_test.rb
  76. +4 −0 episode-250/revised/blog-after/test/unit/helpers/articles_helper_test.rb
  77. +4 −0 episode-250/revised/blog-after/test/unit/helpers/sessions_helper_test.rb
  78. +4 −0 episode-250/revised/blog-after/test/unit/helpers/users_helper_test.rb
  79. +7 −0 episode-250/revised/blog-after/test/unit/user_test.rb
  80. 0 episode-250/revised/blog-after/vendor/assets/javascripts/.gitkeep
  81. 0 episode-250/revised/blog-after/vendor/assets/stylesheets/.gitkeep
  82. 0 episode-250/revised/blog-after/vendor/plugins/.gitkeep
  83. +15 −0 episode-250/revised/blog-before/.gitignore
  84. +38 −0 episode-250/revised/blog-before/Gemfile
  85. +111 −0 episode-250/revised/blog-before/Gemfile.lock
  86. +9 −0 episode-250/revised/blog-before/README.rdoc
  87. +7 −0 episode-250/revised/blog-before/Rakefile
  88. BIN episode-250/revised/blog-before/app/assets/images/rails.png
  89. +15 −0 episode-250/revised/blog-before/app/assets/javascripts/application.js
  90. +3 −0 episode-250/revised/blog-before/app/assets/javascripts/articles.js.coffee
  91. +105 −0 episode-250/revised/blog-before/app/assets/stylesheets/application.css
  92. +24 −0 episode-250/revised/blog-before/app/assets/stylesheets/articles.css.scss
  93. +3 −0 episode-250/revised/blog-before/app/controllers/application_controller.rb
  94. +22 −0 episode-250/revised/blog-before/app/controllers/articles_controller.rb
  95. +2 −0 episode-250/revised/blog-before/app/helpers/application_helper.rb
  96. +2 −0 episode-250/revised/blog-before/app/helpers/articles_helper.rb
  97. 0 episode-250/revised/blog-before/app/mailers/.gitkeep
  98. 0 episode-250/revised/blog-before/app/models/.gitkeep
  99. +3 −0 episode-250/revised/blog-before/app/models/article.rb
  100. +29 −0 episode-250/revised/blog-before/app/views/articles/edit.html.erb
  101. +14 −0 episode-250/revised/blog-before/app/views/articles/index.html.erb
  102. +6 −0 episode-250/revised/blog-before/app/views/articles/show.html.erb
  103. +22 −0 episode-250/revised/blog-before/app/views/layouts/application.html.erb
  104. +4 −0 episode-250/revised/blog-before/config.ru
  105. +59 −0 episode-250/revised/blog-before/config/application.rb
  106. +6 −0 episode-250/revised/blog-before/config/boot.rb
  107. +25 −0 episode-250/revised/blog-before/config/database.yml
  108. +5 −0 episode-250/revised/blog-before/config/environment.rb
  109. +37 −0 episode-250/revised/blog-before/config/environments/development.rb
  110. +67 −0 episode-250/revised/blog-before/config/environments/production.rb
  111. +37 −0 episode-250/revised/blog-before/config/environments/test.rb
  112. +7 −0 episode-250/revised/blog-before/config/initializers/backtrace_silencers.rb
  113. +15 −0 episode-250/revised/blog-before/config/initializers/inflections.rb
  114. +5 −0 episode-250/revised/blog-before/config/initializers/mime_types.rb
  115. +7 −0 episode-250/revised/blog-before/config/initializers/secret_token.rb
  116. +8 −0 episode-250/revised/blog-before/config/initializers/session_store.rb
  117. +14 −0 episode-250/revised/blog-before/config/initializers/wrap_parameters.rb
  118. +5 −0 episode-250/revised/blog-before/config/locales/en.yml
  119. +4 −0 episode-250/revised/blog-before/config/routes.rb
  120. +12 −0 episode-250/revised/blog-before/db/migrate/20120130184408_create_articles.rb
  121. +25 −0 episode-250/revised/blog-before/db/schema.rb
  122. +7 −0 episode-250/revised/blog-before/db/seeds.rb
  123. +2 −0 episode-250/revised/blog-before/doc/README_FOR_APP
  124. 0 episode-250/revised/blog-before/lib/assets/.gitkeep
  125. 0 episode-250/revised/blog-before/lib/tasks/.gitkeep
  126. 0 episode-250/revised/blog-before/log/.gitkeep
  127. +26 −0 episode-250/revised/blog-before/public/404.html
  128. +26 −0 episode-250/revised/blog-before/public/422.html
  129. +25 −0 episode-250/revised/blog-before/public/500.html
  130. 0 episode-250/revised/blog-before/public/favicon.ico
  131. +5 −0 episode-250/revised/blog-before/public/robots.txt
  132. +6 −0 episode-250/revised/blog-before/script/rails
  133. 0 episode-250/revised/blog-before/test/fixtures/.gitkeep
  134. +11 −0 episode-250/revised/blog-before/test/fixtures/articles.yml
  135. 0 episode-250/revised/blog-before/test/functional/.gitkeep
  136. +49 −0 episode-250/revised/blog-before/test/functional/articles_controller_test.rb
  137. 0 episode-250/revised/blog-before/test/integration/.gitkeep
  138. +12 −0 episode-250/revised/blog-before/test/performance/browsing_test.rb
  139. +13 −0 episode-250/revised/blog-before/test/test_helper.rb
  140. 0 episode-250/revised/blog-before/test/unit/.gitkeep
  141. +7 −0 episode-250/revised/blog-before/test/unit/article_test.rb
  142. +4 −0 episode-250/revised/blog-before/test/unit/helpers/articles_helper_test.rb
  143. 0 episode-250/revised/blog-before/vendor/assets/javascripts/.gitkeep
  144. 0 episode-250/revised/blog-before/vendor/assets/stylesheets/.gitkeep
  145. 0 episode-250/revised/blog-before/vendor/plugins/.gitkeep
@@ -0,0 +1,13 @@
+# RailsCasts Episode #250: Authentication from Scratch (revised)
+
+http://railscasts.com/episodes/250-authentication-from-scratch-revised
+
+Requires Ruby 1.9.2 or higher.
+
+Commands used in episode.
+
+```
+rails g resource user email password_digest
+rake db:migrate
+rails g controller sessions new
+```
@@ -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,113 @@
+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)
+ bcrypt-ruby (3.0.1)
+ 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
+ bcrypt-ruby (~> 3.0.0)
+ 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,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,105 @@
+/*
+ * 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;
+ width: 400px;
+}
+
+#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 .info {
+ font-style: italic;
+ color: #333;
+ margin-bottom: 8px;
+ font-size: 12px;
+}
+
+#user_header {
+ float: right;
+}
@@ -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 sessions controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+// Place all the styles related to the users controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,14 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+
+private
+
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+ helper_method :current_user
+
+ def authorize
+ redirect_to login_url, alert: "Not authorized" if current_user.nil?
+ end
+end
Oops, something went wrong.

0 comments on commit 095087e

Please sign in to comment.