Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

automatic import from ryanb/railscasts-episodes

  • Loading branch information...
commit 8e78b721c7cf9b36350c30e6743692e0884c9fa4 0 parents
@gilesbowkett gilesbowkett authored
Showing with 2,040 additions and 0 deletions.
  1. +16 −0 README
  2. +5 −0 auth-after/.gitignore
  3. +1 −0  auth-after/.rspec
  4. +31 −0 auth-after/Gemfile
  5. +157 −0 auth-after/Gemfile.lock
  6. +20 −0 auth-after/Guardfile
  7. +7 −0 auth-after/README
  8. +7 −0 auth-after/Rakefile
  9. BIN  auth-after/app/assets/images/rails.png
  10. +9 −0 auth-after/app/assets/javascripts/application.js
  11. +3 −0  auth-after/app/assets/javascripts/home.js.coffee
  12. +3 −0  auth-after/app/assets/javascripts/password_resets.js.coffee
  13. +3 −0  auth-after/app/assets/javascripts/sessions.js.coffee
  14. +3 −0  auth-after/app/assets/javascripts/users.js.coffee
  15. +91 −0 auth-after/app/assets/stylesheets/application.css
  16. +7 −0 auth-after/app/assets/stylesheets/home.css.scss
  17. +7 −0 auth-after/app/assets/stylesheets/password_resets.css.scss
  18. +7 −0 auth-after/app/assets/stylesheets/sessions.css.scss
  19. +7 −0 auth-after/app/assets/stylesheets/users.css.scss
  20. +10 −0 auth-after/app/controllers/application_controller.rb
  21. +4 −0 auth-after/app/controllers/home_controller.rb
  22. +25 −0 auth-after/app/controllers/password_resets_controller.rb
  23. +20 −0 auth-after/app/controllers/sessions_controller.rb
  24. +14 −0 auth-after/app/controllers/users_controller.rb
  25. +2 −0  auth-after/app/helpers/application_helper.rb
  26. +2 −0  auth-after/app/helpers/home_helper.rb
  27. +2 −0  auth-after/app/helpers/password_resets_helper.rb
  28. +2 −0  auth-after/app/helpers/sessions_helper.rb
  29. +2 −0  auth-after/app/helpers/users_helper.rb
  30. 0  auth-after/app/mailers/.gitkeep
  31. +8 −0 auth-after/app/mailers/user_mailer.rb
  32. 0  auth-after/app/models/.gitkeep
  33. +18 −0 auth-after/app/models/user.rb
  34. +3 −0  auth-after/app/views/home/index.html.erb
  35. +26 −0 auth-after/app/views/layouts/application.html.erb
  36. +23 −0 auth-after/app/views/password_resets/edit.html.erb
  37. +7 −0 auth-after/app/views/password_resets/new.html.erb
  38. +14 −0 auth-after/app/views/sessions/new.html.erb
  39. +5 −0 auth-after/app/views/user_mailer/password_reset.text.erb
  40. +27 −0 auth-after/app/views/users/new.html.erb
  41. +4 −0 auth-after/config.ru
  42. +42 −0 auth-after/config/application.rb
  43. +6 −0 auth-after/config/boot.rb
  44. +25 −0 auth-after/config/database.yml
  45. +5 −0 auth-after/config/environment.rb
  46. +29 −0 auth-after/config/environments/development.rb
  47. +54 −0 auth-after/config/environments/production.rb
  48. +41 −0 auth-after/config/environments/test.rb
  49. +7 −0 auth-after/config/initializers/backtrace_silencers.rb
  50. +10 −0 auth-after/config/initializers/inflections.rb
  51. +5 −0 auth-after/config/initializers/mime_types.rb
  52. +7 −0 auth-after/config/initializers/secret_token.rb
  53. +8 −0 auth-after/config/initializers/session_store.rb
  54. +12 −0 auth-after/config/initializers/wrap_parameters.rb
  55. +5 −0 auth-after/config/locales/en.yml
  56. +9 −0 auth-after/config/routes.rb
  57. +10 −0 auth-after/db/migrate/20110613044221_create_users.rb
  58. +6 −0 auth-after/db/migrate/20110718213551_add_password_reset_to_users.rb
  59. +24 −0 auth-after/db/schema.rb
  60. +7 −0 auth-after/db/seeds.rb
  61. +2 −0  auth-after/doc/README_FOR_APP
  62. 0  auth-after/lib/tasks/.gitkeep
  63. 0  auth-after/log/.gitkeep
  64. +26 −0 auth-after/public/404.html
  65. +26 −0 auth-after/public/422.html
  66. +26 −0 auth-after/public/500.html
  67. 0  auth-after/public/favicon.ico
  68. +5 −0 auth-after/public/robots.txt
  69. +6 −0 auth-after/script/rails
  70. +4 −0 auth-after/spec/factories.rb
  71. +3 −0  auth-after/spec/fixtures/user_mailer/password_reset
  72. +15 −0 auth-after/spec/mailers/user_mailer_spec.rb
  73. +24 −0 auth-after/spec/models/user_spec.rb
  74. +51 −0 auth-after/spec/requests/password_resets_spec.rb
  75. +28 −0 auth-after/spec/spec_helper.rb
  76. +9 −0 auth-after/spec/support/mailer_macros.rb
  77. 0  auth-after/vendor/assets/stylesheets/.gitkeep
  78. 0  auth-after/vendor/plugins/.gitkeep
  79. +5 −0 auth-before/.gitignore
  80. +29 −0 auth-before/Gemfile
  81. +115 −0 auth-before/Gemfile.lock
  82. +7 −0 auth-before/README
  83. +7 −0 auth-before/Rakefile
  84. BIN  auth-before/app/assets/images/rails.png
  85. +9 −0 auth-before/app/assets/javascripts/application.js
  86. +3 −0  auth-before/app/assets/javascripts/home.js.coffee
  87. +3 −0  auth-before/app/assets/javascripts/sessions.js.coffee
  88. +3 −0  auth-before/app/assets/javascripts/users.js.coffee
  89. +91 −0 auth-before/app/assets/stylesheets/application.css
  90. +7 −0 auth-before/app/assets/stylesheets/home.css.scss
  91. +7 −0 auth-before/app/assets/stylesheets/sessions.css.scss
  92. +7 −0 auth-before/app/assets/stylesheets/users.css.scss
  93. +10 −0 auth-before/app/controllers/application_controller.rb
  94. +4 −0 auth-before/app/controllers/home_controller.rb
  95. +20 −0 auth-before/app/controllers/sessions_controller.rb
  96. +14 −0 auth-before/app/controllers/users_controller.rb
  97. +2 −0  auth-before/app/helpers/application_helper.rb
  98. +2 −0  auth-before/app/helpers/home_helper.rb
  99. +2 −0  auth-before/app/helpers/sessions_helper.rb
  100. +2 −0  auth-before/app/helpers/users_helper.rb
  101. 0  auth-before/app/mailers/.gitkeep
  102. 0  auth-before/app/models/.gitkeep
  103. +5 −0 auth-before/app/models/user.rb
  104. +3 −0  auth-before/app/views/home/index.html.erb
  105. +26 −0 auth-before/app/views/layouts/application.html.erb
  106. +13 −0 auth-before/app/views/sessions/new.html.erb
  107. +27 −0 auth-before/app/views/users/new.html.erb
  108. +4 −0 auth-before/config.ru
  109. +42 −0 auth-before/config/application.rb
  110. +6 −0 auth-before/config/boot.rb
  111. +25 −0 auth-before/config/database.yml
  112. +5 −0 auth-before/config/environment.rb
  113. +27 −0 auth-before/config/environments/development.rb
  114. +54 −0 auth-before/config/environments/production.rb
  115. +39 −0 auth-before/config/environments/test.rb
  116. +7 −0 auth-before/config/initializers/backtrace_silencers.rb
  117. +10 −0 auth-before/config/initializers/inflections.rb
  118. +5 −0 auth-before/config/initializers/mime_types.rb
  119. +7 −0 auth-before/config/initializers/secret_token.rb
  120. +8 −0 auth-before/config/initializers/session_store.rb
  121. +12 −0 auth-before/config/initializers/wrap_parameters.rb
  122. +5 −0 auth-before/config/locales/en.yml
  123. +8 −0 auth-before/config/routes.rb
  124. +10 −0 auth-before/db/migrate/20110613044221_create_users.rb
  125. +22 −0 auth-before/db/schema.rb
  126. +7 −0 auth-before/db/seeds.rb
  127. +2 −0  auth-before/doc/README_FOR_APP
  128. 0  auth-before/lib/tasks/.gitkeep
  129. 0  auth-before/log/.gitkeep
  130. +26 −0 auth-before/public/404.html
  131. +26 −0 auth-before/public/422.html
  132. +26 −0 auth-before/public/500.html
  133. 0  auth-before/public/favicon.ico
  134. +5 −0 auth-before/public/robots.txt
  135. +6 −0 auth-before/script/rails
  136. 0  auth-before/test/fixtures/.gitkeep
  137. +9 −0 auth-before/test/fixtures/users.yml
  138. 0  auth-before/test/functional/.gitkeep
  139. +9 −0 auth-before/test/functional/home_controller_test.rb
  140. +9 −0 auth-before/test/functional/sessions_controller_test.rb
  141. +9 −0 auth-before/test/functional/users_controller_test.rb
  142. 0  auth-before/test/integration/.gitkeep
  143. +12 −0 auth-before/test/performance/browsing_test.rb
  144. +13 −0 auth-before/test/test_helper.rb
  145. 0  auth-before/test/unit/.gitkeep
  146. +4 −0 auth-before/test/unit/helpers/home_helper_test.rb
  147. +4 −0 auth-before/test/unit/helpers/secret_helper_test.rb
  148. +4 −0 auth-before/test/unit/helpers/sessions_helper_test.rb
  149. +4 −0 auth-before/test/unit/helpers/users_helper_test.rb
  150. +7 −0 auth-before/test/unit/user_test.rb
  151. 0  auth-before/vendor/assets/stylesheets/.gitkeep
  152. 0  auth-before/vendor/plugins/.gitkeep
16 README
@@ -0,0 +1,16 @@
+RailsCasts Episode #275: How I Test
+
+http://railscasts.com/episodes/275-how-i-test
+
+Commands used in episode
+
+ bundle
+ rails g rspec:install
+ mkdir spec/support spec/models spec/routing
+ guard init rspec
+ gem install rb-fsevent
+ rails g integration_test password_reset
+ rails g controller password_resets new --no-test-framework
+ rails g mailer user_mailer password_reset
+ rails g migration add_password_reset_to_users password_reset_token:string password_reset_sent_at:datetime
+ rake db:migrate
5 auth-after/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
1  auth-after/.rspec
@@ -0,0 +1 @@
+--colour
31 auth-after/Gemfile
@@ -0,0 +1,31 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0.rc4'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+# Asset template engines
+gem 'sass-rails', "~> 3.1.0.rc"
+gem 'coffee-script'
+gem 'uglifier'
+
+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'
+
+gem "rspec-rails", :group => [:test, :development]
+group :test do
+ gem "factory_girl_rails"
+ gem "capybara"
+ gem "guard-rspec"
+end
157 auth-after/Gemfile.lock
@@ -0,0 +1,157 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.0)
+ rack-cache (~> 1.0.1)
+ rack-mount (~> 0.8.1)
+ rack-test (~> 0.6.0)
+ sprockets (~> 2.0.0.beta.10)
+ tzinfo (~> 0.3.27)
+ activemodel (3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ arel (~> 2.1.1)
+ tzinfo (~> 0.3.27)
+ activeresource (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ activesupport (3.1.0.rc4)
+ multi_json (~> 1.0)
+ arel (2.1.1)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ capybara (1.0.0)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 0.2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.1.9)
+ ffi (~> 1.0.6)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.1)
+ diff-lcs (1.1.2)
+ erubis (2.7.0)
+ execjs (1.1.2)
+ multi_json (~> 1.0)
+ factory_girl (1.3.3)
+ factory_girl_rails (1.0.1)
+ factory_girl (~> 1.3)
+ railties (>= 3.0.0)
+ ffi (1.0.9)
+ guard (0.5.1)
+ thor (~> 0.14.6)
+ guard-rspec (0.4.0)
+ guard (>= 0.4.0)
+ hike (1.0.0)
+ i18n (0.6.0)
+ jquery-rails (1.0.9)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json_pure (1.5.3)
+ 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)
+ nokogiri (1.5.0)
+ polyglot (0.3.1)
+ rack (1.3.0)
+ rack-cache (1.0.2)
+ rack (>= 0.4)
+ rack-mount (0.8.1)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.0)
+ rack (>= 1.0)
+ rails (3.1.0.rc4)
+ actionmailer (= 3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activerecord (= 3.1.0.rc4)
+ activeresource (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bundler (~> 1.0)
+ railties (= 3.1.0.rc4)
+ railties (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.6.1)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
+ rubyzip (0.9.4)
+ sass (3.1.2)
+ sass-rails (3.1.0.rc.2)
+ actionpack (~> 3.1.0.rc1)
+ railties (~> 3.1.0.rc1)
+ sass (>= 3.1.2)
+ sprockets (>= 2.0.0.beta.9)
+ selenium-webdriver (0.2.2)
+ childprocess (>= 0.1.9)
+ ffi (>= 1.0.7)
+ json_pure
+ rubyzip
+ sprockets (2.0.0.beta.10)
+ hike (~> 1.0)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.3)
+ thor (0.14.6)
+ tilt (1.3.2)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.27)
+ uglifier (0.5.4)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara
+ coffee-script
+ factory_girl_rails
+ guard-rspec
+ jquery-rails
+ rails (= 3.1.0.rc4)
+ rspec-rails
+ sass-rails (~> 3.1.0.rc)
+ sqlite3
+ uglifier
20 auth-after/Guardfile
@@ -0,0 +1,20 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
7 auth-after/README
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:migrate
+ rails s
7 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
BIN  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.
9 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 .
3  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/
3  auth-after/app/assets/javascripts/password_resets.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/
3  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/
3  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/
91 auth-after/app/assets/stylesheets/application.css
@@ -0,0 +1,91 @@
+/*
+ * 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;
+}
7 auth-after/app/assets/stylesheets/home.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.home {
+ // Place scoped styles here
+}
7 auth-after/app/assets/stylesheets/password_resets.css.scss
@@ -0,0 +1,7 @@
+// Place all the styles related to the password_resets controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+
+body.password-resets {
+ // Place scoped styles here
+}
7 auth-after/app/assets/stylesheets/sessions.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.sessions {
+ // Place scoped styles here
+}
7 auth-after/app/assets/stylesheets/users.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.users {
+ // Place scoped styles here
+}
10 auth-after/app/controllers/application_controller.rb
@@ -0,0 +1,10 @@
+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
+end
4 auth-after/app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
+class HomeController < ApplicationController
+ def index
+ end
+end
25 auth-after/app/controllers/password_resets_controller.rb
@@ -0,0 +1,25 @@
+class PasswordResetsController < ApplicationController
+ def new
+ end
+
+ def create
+ user = User.find_by_email(params[:email])
+ user.send_password_reset if user
+ redirect_to root_url, :notice => "Email sent with password reset instructions."
+ end
+
+ def edit
+ @user = User.find_by_password_reset_token!(params[:id])
+ end
+
+ def update
+ @user = User.find_by_password_reset_token!(params[:id])
+ if @user.password_reset_sent_at < 2.hours.ago
+ redirect_to new_password_reset_path, :alert => "Password reset has expired."
+ elsif @user.update_attributes(params[:user])
+ redirect_to root_url, :notice => "Password has been reset!"
+ else
+ render :edit
+ end
+ end
+end
20 auth-after/app/controllers/sessions_controller.rb
@@ -0,0 +1,20 @@
+class SessionsController < ApplicationController
+ def new
+ end
+
+ def create
+ user = User.find_by_email(params[:email])
+ if user && user.authenticate(params[:password])
+ session[:user_id] = user.id
+ redirect_to root_url, :notice => "Logged in!"
+ else
+ flash.now.alert = "Invalid email or password"
+ render "new"
+ end
+ end
+
+ def destroy
+ session[:user_id] = nil
+ redirect_to root_url, :notice => "Logged out!"
+ end
+end
14 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
2  auth-after/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
2  auth-after/app/helpers/home_helper.rb
@@ -0,0 +1,2 @@
+module HomeHelper
+end
2  auth-after/app/helpers/password_resets_helper.rb
@@ -0,0 +1,2 @@
+module PasswordResetsHelper
+end
2  auth-after/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
2  auth-after/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
0  auth-after/app/mailers/.gitkeep
No changes.
8 auth-after/app/mailers/user_mailer.rb
@@ -0,0 +1,8 @@
+class UserMailer < ActionMailer::Base
+ default from: "from@example.com"
+
+ def password_reset(user)
+ @user = user
+ mail :to => user.email, :subject => "Password Reset"
+ end
+end
0  auth-after/app/models/.gitkeep
No changes.
18 auth-after/app/models/user.rb
@@ -0,0 +1,18 @@
+class User < ActiveRecord::Base
+ attr_accessible :email, :password, :password_confirmation
+ has_secure_password
+ validates_presence_of :password, :on => :create
+
+ def send_password_reset
+ generate_token(:password_reset_token)
+ self.password_reset_sent_at = Time.zone.now
+ save!
+ UserMailer.password_reset(self).deliver
+ end
+
+ def generate_token(column)
+ begin
+ self[column] = SecureRandom.urlsafe_base64
+ end while User.exists?(column => self[column])
+ end
+end
3  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>
26 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 class="<%= params[:controller] %>">
+ <div id="container">
+ <div id="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>
23 auth-after/app/views/password_resets/edit.html.erb
@@ -0,0 +1,23 @@
+<h1>Reset Password</h1>
+
+<%= form_for @user, :url => password_reset_path(params[:id]) 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 :password %>
+ <%= f.password_field :password %>
+ </div>
+ <div class="field">
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ </div>
+ <div class="actions"><%= f.submit "Update Password" %></div>
+<% end %>
7 auth-after/app/views/password_resets/new.html.erb
@@ -0,0 +1,7 @@
+<%= form_tag password_resets_path, :method => :post do %>
+ <div class="field">
+ <%= label_tag :email %>
+ <%= text_field_tag :email, params[:email] %>
+ </div>
+ <div class="actions"><%= submit_tag "Reset Password" %></div>
+<% end %>
14 auth-after/app/views/sessions/new.html.erb
@@ -0,0 +1,14 @@
+<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>
+ <p><%= link_to "forgotten password?", new_password_reset_path %></p>
+ <div class="actions"><%= submit_tag "Log in" %></div>
+<% end %>
5 auth-after/app/views/user_mailer/password_reset.text.erb
@@ -0,0 +1,5 @@
+To reset your password, click the URL below.
+
+<%= edit_password_reset_url(@user.password_reset_token) %>
+
+If you did not request your password to be reset, just ignore this email and your password will continue to stay the same.
27 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 %>
4 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
42 auth-after/config/application.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+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
+ end
+end
6 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'])
25 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
5 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!
29 auth-after/config/environments/development.rb
@@ -0,0 +1,29 @@
+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
+
+ config.action_mailer.default_url_options = { :host => "localhost:3000" }
+end
54 auth-after/config/environments/production.rb
@@ -0,0 +1,54 @@
+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
+
+ # Specify the default JavaScript compressor
+ config.assets.js_compressor = :uglifier
+
+ # 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
41 auth-after/config/environments/test.rb
@@ -0,0 +1,41 @@
+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
+
+ config.action_mailer.default_url_options = { :host => "www.example.com" }
+end
7 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!
10 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
5 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
7 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'
8 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
12 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
5 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"
9 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"
+ root :to => "home#index"
+ resources :users
+ resources :sessions
+ resources :password_resets
+end
10 auth-after/db/migrate/20110613044221_create_users.rb
@@ -0,0 +1,10 @@
+class CreateUsers < ActiveRecord::Migration
+ def change
+ create_table :users do |t|
+ t.string :email
+ t.string :password_digest
+
+ t.timestamps
+ end
+ end
+end
6 auth-after/db/migrate/20110718213551_add_password_reset_to_users.rb
@@ -0,0 +1,6 @@
+class AddPasswordResetToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :password_reset_token, :string
+ add_column :users, :password_reset_sent_at, :datetime
+ end
+end
24 auth-after/db/schema.rb
@@ -0,0 +1,24 @@
+# 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 => 20110718213551) do
+
+ create_table "users", :force => true do |t|
+ t.string "email"
+ t.string "password_digest"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "password_reset_token"
+ t.datetime "password_reset_sent_at"
+ end
+
+end
7 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)
2  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.
0  auth-after/lib/tasks/.gitkeep
No changes.
0  auth-after/log/.gitkeep
No changes.
26 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>
26 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>
26 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>
0  auth-after/public/favicon.ico
No changes.
5 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: /
6 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'
4 auth-after/spec/factories.rb
@@ -0,0 +1,4 @@
+Factory.define :user do |f|
+ f.sequence(:email) { |n| "foo#{n}@example.com" }
+ f.password "secret"
+end
3  auth-after/spec/fixtures/user_mailer/password_reset
@@ -0,0 +1,3 @@
+UserMailer#password_reset
+
+Hi, find me in app/views/user_mailer/password_reset
15 auth-after/spec/mailers/user_mailer_spec.rb
@@ -0,0 +1,15 @@
+require "spec_helper"
+
+describe UserMailer do
+ describe "password_reset" do
+ let(:user) { Factory(:user, :password_reset_token => "anything") }
+ let(:mail) { UserMailer.password_reset(user) }
+
+ it "send user password reset url" do
+ mail.subject.should eq("Password Reset")
+ mail.to.should eq([user.email])
+ mail.from.should eq(["from@example.com"])
+ mail.body.encoded.should match(edit_password_reset_path(user.password_reset_token))
+ end
+ end
+end
24 auth-after/spec/models/user_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe User do
+ describe "#send_password_reset" do
+ let(:user) { Factory(:user) }
+
+ it "generates a unique password_reset_token each time" do
+ user.send_password_reset
+ last_token = user.password_reset_token
+ user.send_password_reset
+ user.password_reset_token.should_not eq(last_token)
+ end
+
+ it "saves the time the password reset was sent" do
+ user.send_password_reset
+ user.reload.password_reset_sent_at.should be_present
+ end
+
+ it "delivers email to user" do
+ user.send_password_reset
+ last_email.to.should include(user.email)
+ end
+ end
+end
51 auth-after/spec/requests/password_resets_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe "PasswordResets" do
+ it "emails user when requesting password reset" do
+ user = Factory(:user)
+ visit login_path
+ click_link "password"
+ fill_in "Email", :with => user.email
+ click_button "Reset Password"
+ current_path.should eq(root_path)
+ page.should have_content("Email sent")
+ last_email.to.should include(user.email)
+ end
+
+ it "does not email invalid user when requesting password reset" do
+ visit login_path
+ click_link "password"
+ fill_in "Email", :with => "nobody@example.com"
+ click_button "Reset Password"
+ current_path.should eq(root_path)
+ page.should have_content("Email sent")
+ last_email.should be_nil
+ end
+
+ it "updates the user password when confirmation matches" do
+ user = Factory(:user, :password_reset_token => "something", :password_reset_sent_at => 1.hour.ago)
+ visit edit_password_reset_path(user.password_reset_token)
+ fill_in "Password", :with => "foobar"
+ click_button "Update Password"
+ page.should have_content("Password doesn't match confirmation")
+ fill_in "Password", :with => "foobar"
+ fill_in "Password confirmation", :with => "foobar"
+ click_button "Update Password"
+ page.should have_content("Password has been reset")
+ end
+
+ it "reports when password token has expired" do
+ user = Factory(:user, :password_reset_token => "something", :password_reset_sent_at => 5.hour.ago)
+ visit edit_password_reset_path(user.password_reset_token)
+ fill_in "Password", :with => "foobar"
+ fill_in "Password confirmation", :with => "foobar"
+ click_button "Update Password"
+ page.should have_content("Password reset has expired")
+ end
+
+ it "raises record not found when password token is invalid" do
+ lambda {
+ visit edit_password_reset_path("invalid")
+ }.should raise_exception(ActiveRecord::RecordNotFound)
+ end
+end
28 auth-after/spec/spec_helper.rb
@@ -0,0 +1,28 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'capybara/rspec'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ config.include(MailerMacros)
+ config.before(:each) { reset_email }
+end
9 auth-after/spec/support/mailer_macros.rb
@@ -0,0 +1,9 @@
+module MailerMacros
+ def last_email
+ ActionMailer::Base.deliveries.last
+ end
+
+ def reset_email
+ ActionMailer::Base.deliveries = []
+ end
+end
0  auth-after/vendor/assets/stylesheets/.gitkeep
No changes.
0  auth-after/vendor/plugins/.gitkeep
No changes.
5 auth-before/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
29 auth-before/Gemfile
@@ -0,0 +1,29 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0.rc4'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+# Asset template engines
+gem 'sass-rails', "~> 3.1.0.rc"
+gem 'coffee-script'
+gem 'uglifier'
+
+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
115 auth-before/Gemfile.lock
@@ -0,0 +1,115 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.0)
+ rack-cache (~> 1.0.1)
+ rack-mount (~> 0.8.1)
+ rack-test (~> 0.6.0)
+ sprockets (~> 2.0.0.beta.10)
+ tzinfo (~> 0.3.27)
+ activemodel (3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ arel (~> 2.1.1)
+ tzinfo (~> 0.3.27)
+ activeresource (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ activesupport (3.1.0.rc4)
+ multi_json (~> 1.0)
+ ansi (1.2.5)
+ arel (2.1.1)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.1)
+ erubis (2.7.0)
+ execjs (1.1.2)
+ multi_json (~> 1.0)
+ hike (1.0.0)
+ i18n (0.6.0)
+ jquery-rails (1.0.9)
+ 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.1)
+ rack (1.3.0)
+ rack-cache (1.0.2)
+ rack (>= 0.4)
+ rack-mount (0.8.1)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.0)
+ rack (>= 1.0)
+ rails (3.1.0.rc4)
+ actionmailer (= 3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activerecord (= 3.1.0.rc4)
+ activeresource (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bundler (~> 1.0)
+ railties (= 3.1.0.rc4)
+ railties (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.6.1)
+ sass (3.1.2)
+ sass-rails (3.1.0.rc.2)
+ actionpack (~> 3.1.0.rc1)
+ railties (~> 3.1.0.rc1)
+ sass (>= 3.1.2)
+ sprockets (>= 2.0.0.beta.9)
+ sprockets (2.0.0.beta.10)
+ hike (~> 1.0)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.3)
+ thor (0.14.6)
+ tilt (1.3.2)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ turn (0.8.2)
+ ansi (>= 1.2.2)
+ tzinfo (0.3.27)
+ uglifier (0.5.4)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-script
+ jquery-rails
+ rails (= 3.1.0.rc4)
+ sass-rails (~> 3.1.0.rc)
+ sqlite3
+ turn
+ uglifier
7 auth-before/README
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:migrate
+ rails s
7 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
BIN  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.
9 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 .
3  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/
3  auth-before/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/
3  auth-before/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/
91 auth-before/app/assets/stylesheets/application.css
@@ -0,0 +1,91 @@
+/*
+ * 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;
+}
7 auth-before/app/assets/stylesheets/home.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.home {
+ // Place scoped styles here
+}
7 auth-before/app/assets/stylesheets/sessions.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.sessions {
+ // Place scoped styles here
+}
7 auth-before/app/assets/stylesheets/users.css.scss
@@ -0,0 +1,7 @@
+// 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/
+
+body.users {
+ // Place scoped styles here
+}
10 auth-before/app/controllers/application_controller.rb
@@ -0,0 +1,10 @@
+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
+end
4 auth-before/app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
+class HomeController < ApplicationController
+ def index
+ end
+end
20 auth-before/app/controllers/sessions_controller.rb
@@ -0,0 +1,20 @@
+class SessionsController < ApplicationController
+ def new
+ end
+
+ def create
+ user = User.find_by_email(params[:email])
+ if user && user.authenticate(params[:password])
+ session[:user_id] = user.id
+ redirect_to root_url, :notice => "Logged in!"
+ else
+ flash.now.alert = "Invalid email or password"
+ render "new"
+ end
+ end
+
+ def destroy
+ session[:user_id] = nil
+ redirect_to root_url, :notice => "Logged out!"
+ end
+end
14 auth-before/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
2  auth-before/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
2  auth-before/app/helpers/home_helper.rb
@@ -0,0 +1,2 @@
+module HomeHelper
+end
2  auth-before/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
2  auth-before/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
0  auth-before/app/mailers/.gitkeep
No changes.
0  auth-before/app/models/.gitkeep
No changes.
5 auth-before/app/models/user.rb
@@ -0,0 +1,5 @@
+class User < ActiveRecord::Base
+ attr_accessible :email, :password, :password_confirmation
+ has_secure_password
+ validates_presence_of :password, :on => :create
+end
3  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>
26 auth-before/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 class="<%= params[:controller] %>">
+ <div id="container">
+ <div id="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>
13 auth-before/app/views/sessions/new.html.erb
@@ -0,0 +1,13 @@
+<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="actions"><%= submit_tag "Log in" %></div>
+<% end %>
27 auth-before/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 %>
4 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
42 auth-before/config/application.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+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
+ end
+end
6 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'])
25 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
5 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!
27 auth-before/config/environments/development.rb
@@ -0,0 +1,27 @@
+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
+end
54 auth-before/config/environments/production.rb
@@ -0,0 +1,54 @@
+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
+
+ # Specify the default JavaScript compressor
+ config.assets.js_compressor = :uglifier
+
+ # 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)