Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding episode 283

  • Loading branch information...
commit 88fe65dbdc3eb14ee5a83730443b3c0ff89f3311 1 parent 5a1839c
@ryanb authored
Showing with 1,944 additions and 0 deletions.
  1. +13 −0 episode-283/README
  2. +5 −0 episode-283/auth-after/.gitignore
  3. +19 −0 episode-283/auth-after/Gemfile
  4. +134 −0 episode-283/auth-after/Gemfile.lock
  5. +7 −0 episode-283/auth-after/README
  6. +7 −0 episode-283/auth-after/Rakefile
  7. BIN  episode-283/auth-after/app/assets/images/rails.png
  8. +9 −0 episode-283/auth-after/app/assets/javascripts/application.js
  9. +3 −0  episode-283/auth-after/app/assets/javascripts/home.js.coffee
  10. +3 −0  episode-283/auth-after/app/assets/javascripts/sessions.js.coffee
  11. +3 −0  episode-283/auth-after/app/assets/javascripts/users.js.coffee
  12. +100 −0 episode-283/auth-after/app/assets/stylesheets/application.css
  13. +3 −0  episode-283/auth-after/app/assets/stylesheets/home.css.scss
  14. +3 −0  episode-283/auth-after/app/assets/stylesheets/sessions.css.scss
  15. +3 −0  episode-283/auth-after/app/assets/stylesheets/users.css.scss
  16. +9 −0 episode-283/auth-after/app/controllers/application_controller.rb
  17. +9 −0 episode-283/auth-after/app/controllers/home_controller.rb
  18. +19 −0 episode-283/auth-after/app/controllers/sessions_controller.rb
  19. +14 −0 episode-283/auth-after/app/controllers/users_controller.rb
  20. +2 −0  episode-283/auth-after/app/helpers/application_helper.rb
  21. +2 −0  episode-283/auth-after/app/helpers/home_helper.rb
  22. +2 −0  episode-283/auth-after/app/helpers/sessions_helper.rb
  23. +2 −0  episode-283/auth-after/app/helpers/users_helper.rb
  24. 0  episode-283/auth-after/app/mailers/.gitkeep
  25. 0  episode-283/auth-after/app/models/.gitkeep
  26. +10 −0 episode-283/auth-after/app/models/user.rb
  27. +3 −0  episode-283/auth-after/app/views/home/index.html.erb
  28. +2 −0  episode-283/auth-after/app/views/home/secret.html.erb
  29. +26 −0 episode-283/auth-after/app/views/layouts/application.html.erb
  30. +17 −0 episode-283/auth-after/app/views/sessions/new.html.erb
  31. +27 −0 episode-283/auth-after/app/views/users/new.html.erb
  32. +4 −0 episode-283/auth-after/config.ru
  33. +48 −0 episode-283/auth-after/config/application.rb
  34. +6 −0 episode-283/auth-after/config/boot.rb
  35. +25 −0 episode-283/auth-after/config/database.yml
  36. +5 −0 episode-283/auth-after/config/environment.rb
  37. +30 −0 episode-283/auth-after/config/environments/development.rb
  38. +57 −0 episode-283/auth-after/config/environments/production.rb
  39. +39 −0 episode-283/auth-after/config/environments/test.rb
  40. +7 −0 episode-283/auth-after/config/initializers/backtrace_silencers.rb
  41. +10 −0 episode-283/auth-after/config/initializers/inflections.rb
  42. +5 −0 episode-283/auth-after/config/initializers/mime_types.rb
  43. +7 −0 episode-283/auth-after/config/initializers/secret_token.rb
  44. +8 −0 episode-283/auth-after/config/initializers/session_store.rb
  45. +178 −0 episode-283/auth-after/config/initializers/sorcery.rb
  46. +12 −0 episode-283/auth-after/config/initializers/wrap_parameters.rb
  47. +5 −0 episode-283/auth-after/config/locales/en.yml
  48. +9 −0 episode-283/auth-after/config/routes.rb
  49. +16 −0 episode-283/auth-after/db/migrate/20110912063145_sorcery_core.rb
  50. +15 −0 episode-283/auth-after/db/migrate/20110912063146_sorcery_remember_me.rb
  51. +28 −0 episode-283/auth-after/db/schema.rb
  52. +7 −0 episode-283/auth-after/db/seeds.rb
  53. +2 −0  episode-283/auth-after/doc/README_FOR_APP
  54. 0  episode-283/auth-after/lib/tasks/.gitkeep
  55. 0  episode-283/auth-after/log/.gitkeep
  56. +26 −0 episode-283/auth-after/public/404.html
  57. +26 −0 episode-283/auth-after/public/422.html
  58. +26 −0 episode-283/auth-after/public/500.html
  59. 0  episode-283/auth-after/public/favicon.ico
  60. +5 −0 episode-283/auth-after/public/robots.txt
  61. +6 −0 episode-283/auth-after/script/rails
  62. 0  episode-283/auth-after/test/fixtures/.gitkeep
  63. +11 −0 episode-283/auth-after/test/fixtures/users.yml
  64. 0  episode-283/auth-after/test/functional/.gitkeep
  65. +9 −0 episode-283/auth-after/test/functional/home_controller_test.rb
  66. +9 −0 episode-283/auth-after/test/functional/secret_controller_test.rb
  67. +9 −0 episode-283/auth-after/test/functional/sessions_controller_test.rb
  68. +9 −0 episode-283/auth-after/test/functional/users_controller_test.rb
  69. 0  episode-283/auth-after/test/integration/.gitkeep
  70. +12 −0 episode-283/auth-after/test/performance/browsing_test.rb
  71. +13 −0 episode-283/auth-after/test/test_helper.rb
  72. 0  episode-283/auth-after/test/unit/.gitkeep
  73. +4 −0 episode-283/auth-after/test/unit/helpers/home_helper_test.rb
  74. +4 −0 episode-283/auth-after/test/unit/helpers/secret_helper_test.rb
  75. +4 −0 episode-283/auth-after/test/unit/helpers/sessions_helper_test.rb
  76. +4 −0 episode-283/auth-after/test/unit/helpers/users_helper_test.rb
  77. +7 −0 episode-283/auth-after/test/unit/user_test.rb
  78. 0  episode-283/auth-after/vendor/assets/stylesheets/.gitkeep
  79. 0  episode-283/auth-after/vendor/plugins/.gitkeep
  80. +5 −0 episode-283/auth-before/.gitignore
  81. +32 −0 episode-283/auth-before/Gemfile
  82. +117 −0 episode-283/auth-before/Gemfile.lock
  83. +7 −0 episode-283/auth-before/README
  84. +7 −0 episode-283/auth-before/Rakefile
  85. BIN  episode-283/auth-before/app/assets/images/rails.png
  86. +9 −0 episode-283/auth-before/app/assets/javascripts/application.js
  87. +3 −0  episode-283/auth-before/app/assets/javascripts/home.js.coffee
  88. +100 −0 episode-283/auth-before/app/assets/stylesheets/application.css
  89. +3 −0  episode-283/auth-before/app/assets/stylesheets/home.css.scss
  90. +3 −0  episode-283/auth-before/app/controllers/application_controller.rb
  91. +7 −0 episode-283/auth-before/app/controllers/home_controller.rb
  92. +2 −0  episode-283/auth-before/app/helpers/application_helper.rb
  93. +2 −0  episode-283/auth-before/app/helpers/home_helper.rb
  94. 0  episode-283/auth-before/app/mailers/.gitkeep
  95. 0  episode-283/auth-before/app/models/.gitkeep
  96. +3 −0  episode-283/auth-before/app/views/home/index.html.erb
  97. +2 −0  episode-283/auth-before/app/views/home/secret.html.erb
  98. +17 −0 episode-283/auth-before/app/views/layouts/application.html.erb
  99. +4 −0 episode-283/auth-before/config.ru
  100. +48 −0 episode-283/auth-before/config/application.rb
  101. +6 −0 episode-283/auth-before/config/boot.rb
  102. +25 −0 episode-283/auth-before/config/database.yml
  103. +5 −0 episode-283/auth-before/config/environment.rb
  104. +30 −0 episode-283/auth-before/config/environments/development.rb
  105. +57 −0 episode-283/auth-before/config/environments/production.rb
  106. +39 −0 episode-283/auth-before/config/environments/test.rb
  107. +7 −0 episode-283/auth-before/config/initializers/backtrace_silencers.rb
  108. +10 −0 episode-283/auth-before/config/initializers/inflections.rb
  109. +5 −0 episode-283/auth-before/config/initializers/mime_types.rb
  110. +7 −0 episode-283/auth-before/config/initializers/secret_token.rb
  111. +8 −0 episode-283/auth-before/config/initializers/session_store.rb
  112. +12 −0 episode-283/auth-before/config/initializers/wrap_parameters.rb
  113. +5 −0 episode-283/auth-before/config/locales/en.yml
  114. +4 −0 episode-283/auth-before/config/routes.rb
  115. +15 −0 episode-283/auth-before/db/schema.rb
  116. +7 −0 episode-283/auth-before/db/seeds.rb
  117. +2 −0  episode-283/auth-before/doc/README_FOR_APP
  118. 0  episode-283/auth-before/lib/tasks/.gitkeep
  119. 0  episode-283/auth-before/log/.gitkeep
  120. +26 −0 episode-283/auth-before/public/404.html
  121. +26 −0 episode-283/auth-before/public/422.html
  122. +26 −0 episode-283/auth-before/public/500.html
  123. 0  episode-283/auth-before/public/favicon.ico
  124. +5 −0 episode-283/auth-before/public/robots.txt
  125. +6 −0 episode-283/auth-before/script/rails
  126. 0  episode-283/auth-before/test/fixtures/.gitkeep
  127. 0  episode-283/auth-before/test/functional/.gitkeep
  128. +9 −0 episode-283/auth-before/test/functional/home_controller_test.rb
  129. +9 −0 episode-283/auth-before/test/functional/secret_controller_test.rb
  130. +9 −0 episode-283/auth-before/test/functional/sessions_controller_test.rb
  131. +9 −0 episode-283/auth-before/test/functional/users_controller_test.rb
  132. 0  episode-283/auth-before/test/integration/.gitkeep
  133. +12 −0 episode-283/auth-before/test/performance/browsing_test.rb
  134. +13 −0 episode-283/auth-before/test/test_helper.rb
  135. 0  episode-283/auth-before/test/unit/.gitkeep
  136. +4 −0 episode-283/auth-before/test/unit/helpers/home_helper_test.rb
  137. +4 −0 episode-283/auth-before/test/unit/helpers/secret_helper_test.rb
  138. +4 −0 episode-283/auth-before/test/unit/helpers/sessions_helper_test.rb
  139. +4 −0 episode-283/auth-before/test/unit/helpers/users_helper_test.rb
  140. 0  episode-283/auth-before/vendor/assets/stylesheets/.gitkeep
  141. 0  episode-283/auth-before/vendor/plugins/.gitkeep
View
13 episode-283/README
@@ -0,0 +1,13 @@
+RailsCasts Episode #283: Sorcery
+
+http://railscasts.com/episodes/283-sorcery
+
+Commands used in episode
+
+ bundle
+ rake sorcery:bootstrap
+ rails g sorcery_migration core remember_me
+ rails g model user --skip-migration
+ rake db:migrate
+ rails g controller users new
+ rails g controller sessions new
View
5 episode-283/auth-after/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
View
19 episode-283/auth-after/Gemfile
@@ -0,0 +1,19 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0'
+gem 'sqlite3'
+
+gem 'jquery-rails'
+
+group :assets do
+ gem 'sass-rails', " ~> 3.1.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+group :test do
+ # Pretty printed test output
+ gem 'turn', :require => false
+end
+
+gem 'sorcery'
View
134 episode-283/auth-after/Gemfile.lock
@@ -0,0 +1,134 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
+ mail (~> 2.3.0)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.0.3)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ bcrypt-ruby (~> 3.0.0)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
+ addressable (2.2.6)
+ ansi (1.3.0)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.0)
+ builder (3.0.0)
+ coffee-rails (3.1.0)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0.rc1)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ erubis (2.7.0)
+ execjs (1.2.4)
+ multi_json (~> 1.0)
+ faraday (0.6.1)
+ addressable (~> 2.2.4)
+ multipart-post (~> 1.1.0)
+ rack (< 2, >= 1.1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.14)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ multipart-post (1.1.3)
+ oauth (0.4.5)
+ oauth2 (0.4.1)
+ faraday (~> 0.6.1)
+ multi_json (>= 0.0.5)
+ polyglot (0.3.2)
+ rack (1.3.2)
+ rack-cache (1.0.3)
+ 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.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
+ bundler (~> 1.0)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ sass (3.1.7)
+ sass-rails (3.1.0)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sorcery (0.6.1)
+ bcrypt-ruby (~> 3.0.0)
+ oauth (~> 0.4.4)
+ oauth (~> 0.4.4)
+ oauth2 (~> 0.4.1)
+ oauth2 (~> 0.4.1)
+ sprockets (2.0.0)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ turn (0.8.2)
+ ansi (>= 1.2.2)
+ tzinfo (0.3.29)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.0)
+ jquery-rails
+ rails (= 3.1.0)
+ sass-rails (~> 3.1.0)
+ sorcery
+ sqlite3
+ turn
+ uglifier
View
7 episode-283/auth-after/README
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:migrate
+ rails s
View
7 episode-283/auth-after/Rakefile
@@ -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__)
+
+Auth::Application.load_tasks
View
BIN  episode-283/auth-after/app/assets/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 episode-283/auth-after/app/assets/javascripts/application.js
@@ -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 .
View
3  episode-283/auth-after/app/assets/javascripts/home.js.coffee
@@ -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/
View
3  episode-283/auth-after/app/assets/javascripts/sessions.js.coffee
@@ -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/
View
3  episode-283/auth-after/app/assets/javascripts/users.js.coffee
@@ -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/
View
100 episode-283/auth-after/app/assets/stylesheets/application.css
@@ -0,0 +1,100 @@
+/*
+ * 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 .
+*/
+
+html, 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;
+}
+
+form label {
+ display: block;
+ margin-bottom: 2px;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+.fieldWithErrors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ 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: 15px 0;
+}
+
+#user_nav {
+ margin: 15px 0;
+}
+
+input[type=checkbox] {
+ float: left;
+ margin-right: 8px;
+}
View
3  episode-283/auth-after/app/assets/stylesheets/home.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the home controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3  episode-283/auth-after/app/assets/stylesheets/sessions.css.scss
@@ -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/
View
3  episode-283/auth-after/app/assets/stylesheets/users.css.scss
@@ -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/
View
9 episode-283/auth-after/app/controllers/application_controller.rb
@@ -0,0 +1,9 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+
+ private
+
+ def not_authenticated
+ redirect_to login_url, :alert => "First login to access this page."
+ end
+end
View
9 episode-283/auth-after/app/controllers/home_controller.rb
@@ -0,0 +1,9 @@
+class HomeController < ApplicationController
+ before_filter :require_login, :only => :secret
+
+ def index
+ end
+
+ def secret
+ end
+end
View
19 episode-283/auth-after/app/controllers/sessions_controller.rb
@@ -0,0 +1,19 @@
+class SessionsController < ApplicationController
+ def new
+ end
+
+ def create
+ user = login(params[:email], params[:password], params[:remember_me])
+ if user
+ redirect_back_or_to root_url, :notice => "Logged in!"
+ else
+ flash.now.alert = "Email or password was invalid"
+ render :new
+ end
+ end
+
+ def destroy
+ logout
+ redirect_to root_url, :notice => "Logged out!"
+ end
+end
View
14 episode-283/auth-after/app/controllers/users_controller.rb
@@ -0,0 +1,14 @@
+class UsersController < ApplicationController
+ def new
+ @user = User.new
+ end
+
+ def create
+ @user = User.new(params[:user])
+ if @user.save
+ redirect_to root_url, :notice => "Signed up!"
+ else
+ render :new
+ end
+ end
+end
View
2  episode-283/auth-after/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
View
2  episode-283/auth-after/app/helpers/home_helper.rb
@@ -0,0 +1,2 @@
+module HomeHelper
+end
View
2  episode-283/auth-after/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
View
2  episode-283/auth-after/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
0  episode-283/auth-after/app/mailers/.gitkeep
No changes.
View
0  episode-283/auth-after/app/models/.gitkeep
No changes.
View
10 episode-283/auth-after/app/models/user.rb
@@ -0,0 +1,10 @@
+class User < ActiveRecord::Base
+ authenticates_with_sorcery!
+
+ attr_accessible :email, :password, :password_confirmation
+
+ validates_confirmation_of :password
+ validates_presence_of :password, :on => :create
+ validates_presence_of :email
+ validates_uniqueness_of :email
+end
View
3  episode-283/auth-after/app/views/home/index.html.erb
@@ -0,0 +1,3 @@
+<h1>Welcome</h1>
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+<p><%= link_to "Visit secret page", secret_path %></p>
View
2  episode-283/auth-after/app/views/home/secret.html.erb
@@ -0,0 +1,2 @@
+<h1>This is secret!</h1>
+<p>Shhh, don't tell anyone.</p>
View
26 episode-283/auth-after/app/views/layouts/application.html.erb
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Auth Example</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+ <div id="container">
+ <div class="user_nav">
+ <% if current_user %>
+ Logged in as <%= current_user.email %>.
+ <%= link_to "Log out", logout_path %>
+ <% else %>
+ <%= link_to "Sign up", signup_path %> or
+ <%= link_to "log in", login_path %>.
+ <% end %>
+ </div>
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ </div>
+</body>
+</html>
View
17 episode-283/auth-after/app/views/sessions/new.html.erb
@@ -0,0 +1,17 @@
+<h1>Log in</h1>
+
+<%= form_tag sessions_path do %>
+ <div class="field">
+ <%= label_tag :email %>
+ <%= text_field_tag :email, params[:email] %>
+ </div>
+ <div class="field">
+ <%= label_tag :password %>
+ <%= password_field_tag :password %>
+ </div>
+ <div class="field">
+ <%= check_box_tag :remember_me, 1, params[:remember_me] %>
+ <%= label_tag :remember_me %>
+ </div>
+ <div class="actions"><%= submit_tag "Log in" %></div>
+<% end %>
View
27 episode-283/auth-after/app/views/users/new.html.erb
@@ -0,0 +1,27 @@
+<h1>Sign Up</h1>
+
+<%= form_for @user do |f| %>
+ <% if @user.errors.any? %>
+ <div class="error_messages">
+ <h2>Form is invalid</h2>
+ <ul>
+ <% for message in @user.errors.full_messages %>
+ <li><%= message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+ <div class="field">
+ <%= f.label :email %>
+ <%= f.text_field :email %>
+ </div>
+ <div class="field">
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+ </div>
+ <div class="field">
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ </div>
+ <div class="actions"><%= f.submit %></div>
+<% end %>
View
4 episode-283/auth-after/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Auth::Application
View
48 episode-283/auth-after/config/application.rb
@@ -0,0 +1,48 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require *Rails.groups(:assets => %w(development test))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Auth
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
View
6 episode-283/auth-after/config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
View
25 episode-283/auth-after/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
5 episode-283/auth-after/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Auth::Application.initialize!
View
30 episode-283/auth-after/config/environments/development.rb
@@ -0,0 +1,30 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+end
View
57 episode-283/auth-after/config/environments/production.rb
@@ -0,0 +1,57 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
+
+ # Generate digests for assets URLs
+ config.assets.digest = true
+
+ # Specifies the header that your server uses for sending files
+ # (comment out if your front-end server doesn't support this)
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
View
39 episode-283/auth-after/config/environments/test.rb
@@ -0,0 +1,39 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
7 episode-283/auth-after/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
10 episode-283/auth-after/config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
View
5 episode-283/auth-after/config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
View
7 episode-283/auth-after/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Auth::Application.config.secret_token = '974bcaccc646dc39283570007277652121e461b4427c0bfbe9aaa893e11f28b850d684ad1bf469d2e3b663692a84a74d1919ab5f49c20bc0c413e5bbcda0f416'
View
8 episode-283/auth-after/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Auth::Application.config.session_store :cookie_store, key: '_auth_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Auth::Application.config.session_store :active_record_store
View
178 episode-283/auth-after/config/initializers/sorcery.rb
@@ -0,0 +1,178 @@
+# The first thing you need to configure is which modules you need in your app.
+# The default is nothing which will include only core features (password encryption, login/logout).
+# Available submodules are: :user_activation, :http_basic_auth, :remember_me,
+# :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :external
+Rails.application.config.sorcery.submodules = [:remember_me]
+
+# Here you can configure each submodule's features.
+Rails.application.config.sorcery.configure do |config|
+ # -- core --
+ # config.not_authenticated_action = :not_authenticated # what controller action to call for
+ # non-authenticated users.
+ # You can also override 'not_authenticated'
+ # instead.
+
+ # config.save_return_to_url = true # when a non logged in user tries to enter
+ # a page that requires login,
+ # save the URL he wanted to reach,
+ # and send him there after login, using
+ # 'redirect_back_or_to'.
+
+ # -- session timeout --
+ # config.session_timeout = 3600 # how long in seconds to keep the session alive.
+ # config.session_timeout_from_last_action = false # use the last action as the beginning of
+ # session timeout.
+
+ # -- http_basic_auth --
+ # config.controller_to_realm_map = {"application" => "Application"} # What realm to display for which controller name.
+ # For example {"My App" => "Application"}
+
+ # -- external --
+ # config.external_providers = [] # What providers are supported by this app,
+ # i.e. [:twitter, :facebook] .
+ #
+ # config.twitter.key = "eYVNBjBDi33aa9GkA3w"
+ # config.twitter.secret = "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8"
+ # config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter"
+ # config.twitter.user_info_mapping = {:email => "screen_name"}
+ #
+ # config.facebook.key = "34cebc81c08a521bc66e212f947d73ec"
+ # config.facebook.secret = "5b458d179f61d4f036ee66a497ffbcd0"
+ # config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
+ # config.facebook.user_info_mapping = {:email => "name"}
+
+ # --- user config ---
+ config.user_config do |user|
+ # -- core --
+ user.username_attribute_name = :email # change default username
+ # attribute, for example,
+ # to use :email as the login.
+
+ # user.password_attribute_name = :password # change *virtual* password
+ # attribute, the one which is used
+ # until an encrypted one is
+ # generated.
+
+ # user.email_attribute_name = :email # change default email attribute.
+
+ # user.crypted_password_attribute_name = :crypted_password # change default crypted_password
+ # attribute.
+
+ # user.salt_join_token = "" # what pattern to use to join the
+ # password with the salt
+
+ # user.salt_attribute_name = :salt # change default salt attribute.
+
+ # user.stretches = nil # how many times to apply
+ # encryption to the password.
+
+ # user.encryption_key = nil # encryption key used to encrypt
+ # reversible encryptions such as
+ # AES256.
+
+ # user.custom_encryption_provider = nil # use an external encryption
+ # class.
+
+ # user.encryption_algorithm = :bcrypt # encryption algorithm name. See
+ # 'encryption_algorithm=' for
+ # available options.
+
+ # user.subclasses_inherit_config = false # make this configuration
+ # inheritable for subclasses.
+ # Useful for ActiveRecord's STI.
+
+ # -- user_activation --
+ # user.activation_state_attribute_name = :activation_state # the attribute name to hold
+ # activation state
+ # (active/pending).
+
+ # user.activation_token_attribute_name = :activation_token # the attribute name to hold
+ # activation code (sent by email).
+
+ # user.activation_token_expires_at_attribute_name = :activation_token_expires_at # the attribute name to hold
+ # activation code expiration date.
+
+ # user.activation_token_expiration_period = nil # how many seconds before the
+ # activation code expires. nil for
+ # never expires.
+
+ # user.user_activation_mailer = nil # your mailer class. Required.
+
+ # user.activation_needed_email_method_name = :activation_needed_email # activation needed email method
+ # on your mailer class.
+
+ # user.activation_success_email_method_name = :activation_success_email # activation success email method
+ # on your mailer class.
+
+ # user.prevent_non_active_users_to_login = true # do you want to prevent or allow
+ # users that did not activate by
+ # email to login?
+
+ # -- reset_password --
+ # user.reset_password_token_attribute_name = :reset_password_token # reset password code
+ # attribute name.
+
+ # user.reset_password_token_expires_at_attribute_name = :reset_password_token_expires_at # expires at attribute
+ # name.
+
+ # user.reset_password_email_sent_at_attribute_name = :reset_password_email_sent_at # when was email sent,
+ # used for hammering
+ # protection.
+
+ # user.reset_password_mailer = nil # mailer class. Needed.
+
+ # user.reset_password_email_method_name = :reset_password_email # reset password email
+ # method on your mailer
+ # class.
+
+ # user.reset_password_expiration_period = nil # how many seconds
+ # before the reset
+ # request expires. nil
+ # for never expires.
+
+ # user.reset_password_time_between_emails = 5 * 60 # hammering protection,
+ # how long to wait
+ # before allowing
+ # another email to be
+ # sent.
+
+ # -- brute_force_protection --
+ # user.failed_logins_count_attribute_name = :failed_logins_count # failed logins attribute name.
+
+ # user.lock_expires_at_attribute_name = :lock_expires_at # this field indicates whether
+ # user is banned and when it will
+ # be active again.
+
+ # user.consecutive_login_retries_amount_limit = 50 # how many failed logins allowed.
+
+ # user.login_lock_time_period = 60 * 60 # how long the user should be
+ # banned. in seconds. 0 for
+ # permanent.
+
+ # -- activity logging --
+ # user.last_login_at_attribute_name = :last_login_at # last login attribute name.
+ # user.last_logout_at_attribute_name = :last_logout_at # last logout attribute name.
+ # user.last_activity_at_attribute_name = :last_activity_at # last activity attribute name.
+ # user.activity_timeout = 10 * 60 # how long since last activity is
+ # the user defined logged out?
+
+ # -- external --
+ # user.authentications_class = nil # class which holds the various
+ # external provider data for this
+ # user.
+
+ # user.authentications_user_id_attribute_name = :user_id # user's identifier in
+ # authentications class.
+
+ # user.provider_attribute_name = :provider # provider's identifier in
+ # authentications class.
+
+ # user.provider_uid_attribute_name = :uid # user's external unique
+ # identifier in authentications
+ # class.
+ end
+
+ # This line must come after the 'user config' block.
+ config.user_class = "User" # define which model authenticates
+ # with sorcery.
+end
View
12 episode-283/auth-after/config/initializers/wrap_parameters.rb
@@ -0,0 +1,12 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActionController::Base.wrap_parameters format: [:json]
+
+# Disable root element in JSON by default.
+if defined?(ActiveRecord)
+ ActiveRecord::Base.include_root_in_json = false
+end
View
5 episode-283/auth-after/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
9 episode-283/auth-after/config/routes.rb
@@ -0,0 +1,9 @@
+Auth::Application.routes.draw do
+ get "logout" => "sessions#destroy", :as => "logout"
+ get "login" => "sessions#new", :as => "login"
+ get "signup" => "users#new", :as => "signup"
+ resources :users
+ resources :sessions
+ get "secret" => "home#secret", :as => "secret"
+ root :to => "home#index"
+end
View
16 episode-283/auth-after/db/migrate/20110912063145_sorcery_core.rb
@@ -0,0 +1,16 @@
+class SorceryCore < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ # t.string :username, :null => false # if you use another filed as a username, for example email, you can safely remove this field.
+ t.string :email, :default => nil # if you use this field as a username, you might want to make it :null => false.
+ t.string :crypted_password, :default => nil
+ t.string :salt, :default => nil
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
View
15 episode-283/auth-after/db/migrate/20110912063146_sorcery_remember_me.rb
@@ -0,0 +1,15 @@
+class SorceryRememberMe < ActiveRecord::Migration
+ def self.up
+ add_column :users, :remember_me_token, :string, :default => nil
+ add_column :users, :remember_me_token_expires_at, :datetime, :default => nil
+
+ add_index :users, :remember_me_token
+ end
+
+ def self.down
+ remove_index :users, :remember_me_token
+
+ remove_column :users, :remember_me_token_expires_at
+ remove_column :users, :remember_me_token
+ end
+end
View
28 episode-283/auth-after/db/schema.rb
@@ -0,0 +1,28 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20110912063146) do
+
+ create_table "users", :force => true do |t|
+ t.string "email"
+ t.string "crypted_password"
+ t.string "salt"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "remember_me_token"
+ t.datetime "remember_me_token_expires_at"
+ end
+
+ add_index "users", ["remember_me_token"], :name => "index_users_on_remember_me_token"
+
+end
View
7 episode-283/auth-after/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
View
2  episode-283/auth-after/doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
View
0  episode-283/auth-after/lib/tasks/.gitkeep
No changes.
View
0  episode-283/auth-after/log/.gitkeep
No changes.
View
26 episode-283/auth-after/public/404.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
View
26 episode-283/auth-after/public/422.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
View
26 episode-283/auth-after/public/500.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
View
0  episode-283/auth-after/public/favicon.ico
No changes.
View
5 episode-283/auth-after/public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-Agent: *
+# Disallow: /
View
6 episode-283/auth-after/script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
View
0  episode-283/auth-after/test/fixtures/.gitkeep
No changes.
View
11 episode-283/auth-after/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
View
0  episode-283/auth-after/test/functional/.gitkeep
No changes.
View
9 episode-283/auth-after/test/functional/home_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class HomeControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+end
View
9 episode-283/auth-after/test/functional/secret_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class SecretControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+end
View
9 episode-283/auth-after/test/functional/sessions_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionController::TestCase
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+end
View
9 episode-283/auth-after/test/functional/users_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+end
View
0  episode-283/auth-after/test/integration/.gitkeep
No changes.
View
12 episode-283/auth-after/test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
View
13 episode-283/auth-after/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
View
0  episode-283/auth-after/test/unit/.gitkeep
No changes.
View
4 episode-283/auth-after/test/unit/helpers/home_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class HomeHelperTest < ActionView::TestCase
+end
View
4 episode-283/auth-after/test/unit/helpers/secret_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SecretHelperTest < ActionView::TestCase
+end
View
4 episode-283/auth-after/test/unit/helpers/sessions_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SessionsHelperTest < ActionView::TestCase
+end
View
4 episode-283/auth-after/test/unit/helpers/users_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class UsersHelperTest < ActionView::TestCase
+end
View
7 episode-283/auth-after/test/unit/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
0  episode-283/auth-after/vendor/assets/stylesheets/.gitkeep
No changes.
View
0  episode-283/auth-after/vendor/plugins/.gitkeep
No changes.
View
5 episode-283/auth-before/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
View
32 episode-283/auth-before/Gemfile
@@ -0,0 +1,32 @@
+source 'http://rubygems.org'
+
+gem "rails", '3.1.0'
+
+# 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.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
+
+# 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', :require => false
+end
View
117 episode-283/auth-before/Gemfile.lock
@@ -0,0 +1,117 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
+ mail (~> 2.3.0)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.0.3)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ bcrypt-ruby (~> 3.0.0)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
+ ansi (1.3.0)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.0)
+ builder (3.0.0)
+ coffee-rails (3.1.0)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0.rc1)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ erubis (2.7.0)
+ execjs (1.2.4)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.14)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ polyglot (0.3.2)
+ rack (1.3.2)
+ rack-cache (1.0.3)
+ 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.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
+ bundler (~> 1.0)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ sass (3.1.7)
+ sass-rails (3.1.0)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sprockets (2.0.0)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ turn (0.8.2)
+ ansi (>= 1.2.2)
+ tzinfo (0.3.29)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.0)
+ jquery-rails
+ rails (= 3.1.0)
+ sass-rails (~> 3.1.0)
+ sqlite3
+ turn
+ uglifier
View
7 episode-283/auth-before/README
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:migrate
+ rails s
View
7 episode-283/auth-before/Rakefile
@@ -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__)
+
+Auth::Application.load_tasks
View
BIN  episode-283/auth-before/app/assets/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 episode-283/auth-before/app/assets/javascripts/application.js
@@ -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 .
View
3  episode-283/auth-before/app/assets/javascripts/home.js.coffee
@@ -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/
View
100 episode-283/auth-before/app/assets/stylesheets/application.css
@@ -0,0 +1,100 @@
+/*
+ * 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 .
+*/
+
+html, 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;
+}
+
+form label {
+ display: block;
+ margin-bottom: 2px;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+.fieldWithErrors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ 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: 15px 0;
+}
+
+#user_nav {
+ margin: 15px 0;
+}
+
+input[type=checkbox] {
+ float: left;
+ margin-right: 8px;
+}
View
3  episode-283/auth-before/app/assets/stylesheets/home.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the home controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3  episode-283/auth-before/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
View
7 episode-283/auth-before/app/controllers/home_controller.rb
@@ -0,0 +1,7 @@
+class HomeController < ApplicationController
+ def index
+ end
+
+ def secret
+ end
+end
View
2  episode-283/auth-before/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
View
2  episode-283/auth-before/app/helpers/home_helper.rb
@@ -0,0 +1,2 @@
+module HomeHelper
+end
View
0  episode-283/auth-before/app/mailers/.gitkeep
No changes.
View
0  episode-283/auth-before/app/models/.gitkeep
No changes.
View
3  episode-283/auth-before/app/views/home/index.html.erb
@@ -0,0 +1,3 @@
+<h1>Welcome</h1>
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+<p><%= link_to "Visit secret page", secret_path %></p>
View
2  episode-283/auth-before/app/views/home/secret.html.erb
@@ -0,0 +1,2 @@
+<h1>This is secret!</h1>
+<p>Shhh, don't tell anyone.</p>
View
17 episode-283/auth-before/app/views/layouts/application.html.erb
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Auth Example</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body class="<%= params[:controller] %>">
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ </div>
+</body>
+</html>
View
4 episode-283/auth-before/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Auth::Application
View
48 episode-283/auth-before/config/application.rb
@@ -0,0 +1,48 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require *Rails.groups(:assets => %w(development test))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Auth
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
View
6 episode-283/auth-before/config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
View
25 episode-283/auth-before/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
5 episode-283/auth-before/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Auth::Application.initialize!
View
30 episode-283/auth-before/config/environments/development.rb
@@ -0,0 +1,30 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+end
View
57 episode-283/auth-before/config/environments/production.rb
@@ -0,0 +1,57 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
+
+ # Generate digests for assets URLs
+ config.assets.digest = true
+
+ # Specifies the header that your server uses for sending files
+ # (comment out if your front-end server doesn't support this)
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
View
39 episode-283/auth-before/config/environments/test.rb
@@ -0,0 +1,39 @@
+Auth::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
7 episode-283/auth-before/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
10 episode-283/auth-before/config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
View
5 episode-283/auth-before/config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
View
7 episode-283/auth-before/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Auth::Application.config.secret_token = '974bcaccc646dc39283570007277652121e461b4427c0bfbe9aaa893e11f28b850d684ad1bf469d2e3b663692a84a74d1919ab5f49c20bc0c413e5bbcda0f416'
View
8 episode-283/auth-before/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Auth::Application.config.session_store :cookie_store, key: '_auth_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Auth::Application.config.session_store :active_record_store
View
12 episode-283/auth-before/config/initializers/wrap_parameters.rb
@@ -0,0 +1,12 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActionController::Base.wrap_parameters format: [:json]
+
+# Disable root element in JSON by default.
+if defined?(ActiveRecord)
+ ActiveRecord::Base.include_root_in_json = false
+end
View
5 episode-283/auth-before/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
4 episode-283/auth-before/config/routes.rb
@@ -0,0 +1,4 @@
+Auth::Application.routes.draw do
+ get "secret" => "home#secret", :as => "secret"
+ root :to => "home#index"
+end
View
15 episode-283/auth-before/db/schema.rb
@@ -0,0 +1,15 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 0) do
+
+end
View
7 episode-283/auth-before/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
View
2  episode-283/auth-before/doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.