Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding episode 274

  • Loading branch information...
commit bb381ad6f1f5fe8b49f50bf28c094806d6e2360e 1 parent 66b49e6
@ryanb authored
Showing with 2,478 additions and 0 deletions.
  1. +11 −0 episode-274/README
  2. +5 −0 episode-274/auth-after/.gitignore
  3. +29 −0 episode-274/auth-after/Gemfile
  4. +115 −0 episode-274/auth-after/Gemfile.lock
  5. +261 −0 episode-274/auth-after/README
  6. +7 −0 episode-274/auth-after/Rakefile
  7. BIN  episode-274/auth-after/app/assets/images/rails.png
  8. +9 −0 episode-274/auth-after/app/assets/javascripts/application.js
  9. +3 −0  episode-274/auth-after/app/assets/javascripts/home.js.coffee
  10. +3 −0  episode-274/auth-after/app/assets/javascripts/password_resets.js.coffee
  11. +3 −0  episode-274/auth-after/app/assets/javascripts/sessions.js.coffee
  12. +3 −0  episode-274/auth-after/app/assets/javascripts/users.js.coffee
  13. +96 −0 episode-274/auth-after/app/assets/stylesheets/application.css
  14. +7 −0 episode-274/auth-after/app/assets/stylesheets/home.css.scss
  15. +7 −0 episode-274/auth-after/app/assets/stylesheets/password_resets.css.scss
  16. +7 −0 episode-274/auth-after/app/assets/stylesheets/sessions.css.scss
  17. +7 −0 episode-274/auth-after/app/assets/stylesheets/users.css.scss
  18. +10 −0 episode-274/auth-after/app/controllers/application_controller.rb
  19. +4 −0 episode-274/auth-after/app/controllers/home_controller.rb
  20. +25 −0 episode-274/auth-after/app/controllers/password_resets_controller.rb
  21. +24 −0 episode-274/auth-after/app/controllers/sessions_controller.rb
  22. +14 −0 episode-274/auth-after/app/controllers/users_controller.rb
  23. +2 −0  episode-274/auth-after/app/helpers/application_helper.rb
  24. +2 −0  episode-274/auth-after/app/helpers/home_helper.rb
  25. +2 −0  episode-274/auth-after/app/helpers/password_resets_helper.rb
  26. +2 −0  episode-274/auth-after/app/helpers/sessions_helper.rb
  27. +2 −0  episode-274/auth-after/app/helpers/users_helper.rb
  28. 0  episode-274/auth-after/app/mailers/.gitkeep
  29. +13 −0 episode-274/auth-after/app/mailers/user_mailer.rb
  30. 0  episode-274/auth-after/app/models/.gitkeep
  31. +19 −0 episode-274/auth-after/app/models/user.rb
  32. +3 −0  episode-274/auth-after/app/views/home/index.html.erb
  33. +26 −0 episode-274/auth-after/app/views/layouts/application.html.erb
  34. +23 −0 episode-274/auth-after/app/views/password_resets/edit.html.erb
  35. +9 −0 episode-274/auth-after/app/views/password_resets/new.html.erb
  36. +18 −0 episode-274/auth-after/app/views/sessions/new.html.erb
  37. +5 −0 episode-274/auth-after/app/views/user_mailer/password_reset.text.erb
  38. +27 −0 episode-274/auth-after/app/views/users/new.html.erb
  39. +4 −0 episode-274/auth-after/config.ru
  40. +42 −0 episode-274/auth-after/config/application.rb
  41. +6 −0 episode-274/auth-after/config/boot.rb
  42. +25 −0 episode-274/auth-after/config/database.yml
  43. +5 −0 episode-274/auth-after/config/environment.rb
  44. +29 −0 episode-274/auth-after/config/environments/development.rb
  45. +54 −0 episode-274/auth-after/config/environments/production.rb
  46. +39 −0 episode-274/auth-after/config/environments/test.rb
  47. +7 −0 episode-274/auth-after/config/initializers/backtrace_silencers.rb
  48. +10 −0 episode-274/auth-after/config/initializers/inflections.rb
  49. +5 −0 episode-274/auth-after/config/initializers/mime_types.rb
  50. +7 −0 episode-274/auth-after/config/initializers/secret_token.rb
  51. +8 −0 episode-274/auth-after/config/initializers/session_store.rb
  52. +12 −0 episode-274/auth-after/config/initializers/wrap_parameters.rb
  53. +5 −0 episode-274/auth-after/config/locales/en.yml
  54. +9 −0 episode-274/auth-after/config/routes.rb
  55. +10 −0 episode-274/auth-after/db/migrate/20110613044221_create_users.rb
  56. +5 −0 episode-274/auth-after/db/migrate/20110711052201_add_auth_token_to_users.rb
  57. +6 −0 episode-274/auth-after/db/migrate/20110711061937_add_password_reset_to_users.rb
  58. +25 −0 episode-274/auth-after/db/schema.rb
  59. +7 −0 episode-274/auth-after/db/seeds.rb
  60. +2 −0  episode-274/auth-after/doc/README_FOR_APP
  61. 0  episode-274/auth-after/lib/tasks/.gitkeep
  62. 0  episode-274/auth-after/log/.gitkeep
  63. +26 −0 episode-274/auth-after/public/404.html
  64. +26 −0 episode-274/auth-after/public/422.html
  65. +26 −0 episode-274/auth-after/public/500.html
  66. 0  episode-274/auth-after/public/favicon.ico
  67. +5 −0 episode-274/auth-after/public/robots.txt
  68. +6 −0 episode-274/auth-after/script/rails
  69. 0  episode-274/auth-after/test/fixtures/.gitkeep
  70. +9 −0 episode-274/auth-after/test/fixtures/users.yml
  71. 0  episode-274/auth-after/test/functional/.gitkeep
  72. +9 −0 episode-274/auth-after/test/functional/home_controller_test.rb
  73. +9 −0 episode-274/auth-after/test/functional/password_resets_controller_test.rb
  74. +9 −0 episode-274/auth-after/test/functional/sessions_controller_test.rb
  75. +12 −0 episode-274/auth-after/test/functional/user_mailer_test.rb
  76. +9 −0 episode-274/auth-after/test/functional/users_controller_test.rb
  77. 0  episode-274/auth-after/test/integration/.gitkeep
  78. +12 −0 episode-274/auth-after/test/performance/browsing_test.rb
  79. +13 −0 episode-274/auth-after/test/test_helper.rb
  80. 0  episode-274/auth-after/test/unit/.gitkeep
  81. +4 −0 episode-274/auth-after/test/unit/helpers/home_helper_test.rb
  82. +4 −0 episode-274/auth-after/test/unit/helpers/password_resets_helper_test.rb
  83. +4 −0 episode-274/auth-after/test/unit/helpers/secret_helper_test.rb
  84. +4 −0 episode-274/auth-after/test/unit/helpers/sessions_helper_test.rb
  85. +4 −0 episode-274/auth-after/test/unit/helpers/users_helper_test.rb
  86. +7 −0 episode-274/auth-after/test/unit/user_test.rb
  87. 0  episode-274/auth-after/vendor/assets/stylesheets/.gitkeep
  88. 0  episode-274/auth-after/vendor/plugins/.gitkeep
  89. +5 −0 episode-274/auth-before/.gitignore
  90. +29 −0 episode-274/auth-before/Gemfile
  91. +115 −0 episode-274/auth-before/Gemfile.lock
  92. +261 −0 episode-274/auth-before/README
  93. +7 −0 episode-274/auth-before/Rakefile
  94. BIN  episode-274/auth-before/app/assets/images/rails.png
  95. +9 −0 episode-274/auth-before/app/assets/javascripts/application.js
  96. +3 −0  episode-274/auth-before/app/assets/javascripts/home.js.coffee
  97. +3 −0  episode-274/auth-before/app/assets/javascripts/sessions.js.coffee
  98. +3 −0  episode-274/auth-before/app/assets/javascripts/users.js.coffee
  99. +91 −0 episode-274/auth-before/app/assets/stylesheets/application.css
  100. +7 −0 episode-274/auth-before/app/assets/stylesheets/home.css.scss
  101. +7 −0 episode-274/auth-before/app/assets/stylesheets/sessions.css.scss
  102. +7 −0 episode-274/auth-before/app/assets/stylesheets/users.css.scss
  103. +10 −0 episode-274/auth-before/app/controllers/application_controller.rb
  104. +4 −0 episode-274/auth-before/app/controllers/home_controller.rb
  105. +20 −0 episode-274/auth-before/app/controllers/sessions_controller.rb
  106. +14 −0 episode-274/auth-before/app/controllers/users_controller.rb
  107. +2 −0  episode-274/auth-before/app/helpers/application_helper.rb
  108. +2 −0  episode-274/auth-before/app/helpers/home_helper.rb
  109. +2 −0  episode-274/auth-before/app/helpers/sessions_helper.rb
  110. +2 −0  episode-274/auth-before/app/helpers/users_helper.rb
  111. 0  episode-274/auth-before/app/mailers/.gitkeep
  112. 0  episode-274/auth-before/app/models/.gitkeep
  113. +5 −0 episode-274/auth-before/app/models/user.rb
  114. +3 −0  episode-274/auth-before/app/views/home/index.html.erb
  115. +26 −0 episode-274/auth-before/app/views/layouts/application.html.erb
  116. +13 −0 episode-274/auth-before/app/views/sessions/new.html.erb
  117. +27 −0 episode-274/auth-before/app/views/users/new.html.erb
  118. +4 −0 episode-274/auth-before/config.ru
  119. +42 −0 episode-274/auth-before/config/application.rb
  120. +6 −0 episode-274/auth-before/config/boot.rb
  121. +25 −0 episode-274/auth-before/config/database.yml
  122. +5 −0 episode-274/auth-before/config/environment.rb
  123. +27 −0 episode-274/auth-before/config/environments/development.rb
  124. +54 −0 episode-274/auth-before/config/environments/production.rb
  125. +39 −0 episode-274/auth-before/config/environments/test.rb
  126. +7 −0 episode-274/auth-before/config/initializers/backtrace_silencers.rb
  127. +10 −0 episode-274/auth-before/config/initializers/inflections.rb
  128. +5 −0 episode-274/auth-before/config/initializers/mime_types.rb
  129. +7 −0 episode-274/auth-before/config/initializers/secret_token.rb
  130. +8 −0 episode-274/auth-before/config/initializers/session_store.rb
  131. +12 −0 episode-274/auth-before/config/initializers/wrap_parameters.rb
  132. +5 −0 episode-274/auth-before/config/locales/en.yml
  133. +8 −0 episode-274/auth-before/config/routes.rb
  134. +10 −0 episode-274/auth-before/db/migrate/20110613044221_create_users.rb
  135. +22 −0 episode-274/auth-before/db/schema.rb
  136. +7 −0 episode-274/auth-before/db/seeds.rb
  137. +2 −0  episode-274/auth-before/doc/README_FOR_APP
  138. 0  episode-274/auth-before/lib/tasks/.gitkeep
  139. 0  episode-274/auth-before/log/.gitkeep
  140. +26 −0 episode-274/auth-before/public/404.html
  141. +26 −0 episode-274/auth-before/public/422.html
  142. +26 −0 episode-274/auth-before/public/500.html
  143. 0  episode-274/auth-before/public/favicon.ico
  144. +5 −0 episode-274/auth-before/public/robots.txt
  145. +6 −0 episode-274/auth-before/script/rails
  146. 0  episode-274/auth-before/test/fixtures/.gitkeep
  147. +9 −0 episode-274/auth-before/test/fixtures/users.yml
  148. 0  episode-274/auth-before/test/functional/.gitkeep
  149. +9 −0 episode-274/auth-before/test/functional/home_controller_test.rb
  150. +9 −0 episode-274/auth-before/test/functional/sessions_controller_test.rb
  151. +9 −0 episode-274/auth-before/test/functional/users_controller_test.rb
  152. 0  episode-274/auth-before/test/integration/.gitkeep
  153. +12 −0 episode-274/auth-before/test/performance/browsing_test.rb
  154. +13 −0 episode-274/auth-before/test/test_helper.rb
  155. 0  episode-274/auth-before/test/unit/.gitkeep
  156. +4 −0 episode-274/auth-before/test/unit/helpers/home_helper_test.rb
  157. +4 −0 episode-274/auth-before/test/unit/helpers/secret_helper_test.rb
  158. +4 −0 episode-274/auth-before/test/unit/helpers/sessions_helper_test.rb
  159. +4 −0 episode-274/auth-before/test/unit/helpers/users_helper_test.rb
  160. +7 −0 episode-274/auth-before/test/unit/user_test.rb
  161. 0  episode-274/auth-before/vendor/assets/stylesheets/.gitkeep
  162. 0  episode-274/auth-before/vendor/plugins/.gitkeep
View
11 episode-274/README
@@ -0,0 +1,11 @@
+RailsCasts Episode #274: Remember Me & Reset Password
+
+http://railscasts.com/episodes/274-remember-me-reset-password
+
+Commands used in episode
+
+ rails g migration add_auth_token_to_users auth_token:string
+ rake db:migrate
+ rails g controller password_resets new
+ rails g migration add_password_reset_to_users password_reset_token:string password_reset_sent_at:datetime
+ rails g mailer user_mailer password_reset
View
5 episode-274/auth-after/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
View
29 episode-274/auth-after/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
View
115 episode-274/auth-after/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
View
261 episode-274/auth-after/README
@@ -0,0 +1,261 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.all
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.org/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- assets
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ |-- assets
+ `-- stylesheets
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/assets
+ Contains subdirectories for images, stylesheets, and JavaScript files.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
View
7 episode-274/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-274/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-274/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-274/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-274/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/
View
3  episode-274/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-274/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
96 episode-274/auth-after/app/assets/stylesheets/application.css
@@ -0,0 +1,96 @@
+/*
+ * 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;
+}
+
+input[type=checkbox] {
+ float: left;
+ margin-right: 8px;
+}
View
7 episode-274/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
+}
View
7 episode-274/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
+}
View
7 episode-274/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
+}
View
7 episode-274/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
+}
View
10 episode-274/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_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
+ end
+ helper_method :current_user
+end
View
4 episode-274/auth-after/app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
+class HomeController < ApplicationController
+ def index
+ end
+end
View
25 episode-274/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
View
24 episode-274/auth-after/app/controllers/sessions_controller.rb
@@ -0,0 +1,24 @@
+class SessionsController < ApplicationController
+ def new
+ end
+
+ def create
+ user = User.find_by_email(params[:email])
+ if user && user.authenticate(params[:password])
+ if params[:remember_me]
+ cookies.permanent[:auth_token] = user.auth_token
+ else
+ cookies[:auth_token] = user.auth_token
+ end
+ redirect_to root_url, :notice => "Logged in!"
+ else
+ flash.now.alert = "Invalid email or password"
+ render "new"
+ end
+ end
+
+ def destroy
+ cookies.delete(:auth_token)
+ redirect_to root_url, :notice => "Logged out!"
+ end
+end
View
14 episode-274/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-274/auth-after/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
View
2  episode-274/auth-after/app/helpers/home_helper.rb
@@ -0,0 +1,2 @@
+module HomeHelper
+end
View
2  episode-274/auth-after/app/helpers/password_resets_helper.rb
@@ -0,0 +1,2 @@
+module PasswordResetsHelper
+end
View
2  episode-274/auth-after/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
View
2  episode-274/auth-after/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
0  episode-274/auth-after/app/mailers/.gitkeep
No changes.
View
13 episode-274/auth-after/app/mailers/user_mailer.rb
@@ -0,0 +1,13 @@
+class UserMailer < ActionMailer::Base
+ default from: "from@example.com"
+
+ # Subject can be set in your I18n file at config/locales/en.yml
+ # with the following lookup:
+ #
+ # en.user_mailer.password_reset.subject
+ #
+ def password_reset(user)
+ @user = user
+ mail :to => user.email, :subject => "Password Reset"
+ end
+end
View
0  episode-274/auth-after/app/models/.gitkeep
No changes.
View
19 episode-274/auth-after/app/models/user.rb
@@ -0,0 +1,19 @@
+class User < ActiveRecord::Base
+ attr_accessible :email, :password, :password_confirmation
+ has_secure_password
+ validates_presence_of :password, :on => :create
+ before_create { generate_token(:auth_token) }
+
+ 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
View
3  episode-274/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>
View
26 episode-274/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>
View
23 episode-274/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 %>
View
9 episode-274/auth-after/app/views/password_resets/new.html.erb
@@ -0,0 +1,9 @@
+<h1>Reset Password</h1>
+
+<%= 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 %>
View
18 episode-274/auth-after/app/views/sessions/new.html.erb
@@ -0,0 +1,18 @@
+<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="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
5 episode-274/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.
View
27 episode-274/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-274/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
42 episode-274/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
View
6 episode-274/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-274/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-274/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
29 episode-274/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
View
54 episode-274/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
View
39 episode-274/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-274/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-274/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-274/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-274/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-274/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
12 episode-274/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-274/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-274/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
View
10 episode-274/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
View
5 episode-274/auth-after/db/migrate/20110711052201_add_auth_token_to_users.rb
@@ -0,0 +1,5 @@
+class AddAuthTokenToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :auth_token, :string
+ end
+end
View
6 episode-274/auth-after/db/migrate/20110711061937_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
View
25 episode-274/auth-after/db/schema.rb
@@ -0,0 +1,25 @@
+# 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 => 20110711061937) 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 "auth_token"
+ t.string "password_reset_token"
+ t.datetime "password_reset_sent_at"
+ end
+
+end
View
7 episode-274/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-274/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-274/auth-after/lib/tasks/.gitkeep
No changes.
View
0  episode-274/auth-after/log/.gitkeep
No changes.
View
26 episode-274/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-274/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-274/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-274/auth-after/public/favicon.ico
No changes.
View
5 episode-274/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-274/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-274/auth-after/test/fixtures/.gitkeep
No changes.
View
9 episode-274/auth-after/test/fixtures/users.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
+
+one:
+ email: MyString
+ password_digest: MyString
+
+two:
+ email: MyString
+ password_digest: MyString
View
0  episode-274/auth-after/test/functional/.gitkeep
No changes.
View
9 episode-274/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-274/auth-after/test/functional/password_resets_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class PasswordResetsControllerTest < ActionController::TestCase
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+end
View
9 episode-274/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
12 episode-274/auth-after/test/functional/user_mailer_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+
+class UserMailerTest < ActionMailer::TestCase
+ test "password_reset" do
+ mail = UserMailer.password_reset
+ assert_equal "Password reset", mail.subject
+ assert_equal ["to@example.org"], mail.to
+ assert_equal ["from@example.com"], mail.from
+ assert_match "Hi", mail.body.encoded
+ end
+
+end
View
9 episode-274/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-274/auth-after/test/integration/.gitkeep
No changes.
View
12 episode-274/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-274/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-274/auth-after/test/unit/.gitkeep
No changes.
View
4 episode-274/auth-after/test/unit/helpers/home_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class HomeHelperTest < ActionView::TestCase
+end
View
4 episode-274/auth-after/test/unit/helpers/password_resets_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PasswordResetsHelperTest < ActionView::TestCase
+end
View
4 episode-274/auth-after/test/unit/helpers/secret_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SecretHelperTest < ActionView::TestCase
+end
View
4 episode-274/auth-after/test/unit/helpers/sessions_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SessionsHelperTest < ActionView::TestCase
+end
View
4 episode-274/auth-after/test/unit/helpers/users_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class UsersHelperTest < ActionView::TestCase
+end
View
7 episode-274/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-274/auth-after/vendor/assets/stylesheets/.gitkeep
No changes.
View
0  episode-274/auth-after/vendor/plugins/.gitkeep
No changes.
View
5 episode-274/auth-before/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
View
29 episode-274/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
View
115 episode-274/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
View
261 episode-274/auth-before/README
@@ -0,0 +1,261 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.all
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.org/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- assets
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ |-- assets
+ `-- stylesheets
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/assets
+ Contains subdirectories for images, stylesheets, and JavaScript files.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
View
7 episode-274/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-274/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-274/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-274/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
3  episode-274/auth-before/app/assets/javascripts/sessions.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.