Skip to content
This repository
Browse code

adding episodes 302 and 303

  • Loading branch information...
commit 92d1a6708addea545f93aa2a0d3924348ee68949 1 parent 2e73455
Ryan Bates authored

Showing 131 changed files with 1,868 additions and 0 deletions. Show diff stats Hide diff stats

  1. +5 0 episode-302/README
  2. +15 0 episode-302/profile-after/.gitignore
  3. +18 0 episode-302/profile-after/Gemfile
  4. +118 0 episode-302/profile-after/Gemfile.lock
  5. +9 0 episode-302/profile-after/README
  6. +7 0 episode-302/profile-after/Rakefile
  7. BIN  episode-302/profile-after/app/assets/images/rails.png
  8. +11 0 episode-302/profile-after/app/assets/javascripts/application.js
  9. +5 0 episode-302/profile-after/app/assets/javascripts/users.js.coffee
  10. +85 0 episode-302/profile-after/app/assets/stylesheets/application.css
  11. +13 0 episode-302/profile-after/app/assets/stylesheets/users.css.scss
  12. +3 0  episode-302/profile-after/app/controllers/application_controller.rb
  13. +40 0 episode-302/profile-after/app/controllers/users_controller.rb
  14. +2 0  episode-302/profile-after/app/helpers/application_helper.rb
  15. +2 0  episode-302/profile-after/app/helpers/users_helper.rb
  16. 0  episode-302/profile-after/app/mailers/.gitkeep
  17. 0  episode-302/profile-after/app/models/.gitkeep
  18. +4 0 episode-302/profile-after/app/models/user.rb
  19. +17 0 episode-302/profile-after/app/views/layouts/application.html.erb
  20. +37 0 episode-302/profile-after/app/views/users/_form.html.erb
  21. +3 0  episode-302/profile-after/app/views/users/edit.html.erb
  22. +7 0 episode-302/profile-after/app/views/users/index.html.erb
  23. +5 0 episode-302/profile-after/app/views/users/new.html.erb
  24. +23 0 episode-302/profile-after/app/views/users/show.html.erb
  25. +4 0 episode-302/profile-after/config.ru
  26. +48 0 episode-302/profile-after/config/application.rb
  27. +6 0 episode-302/profile-after/config/boot.rb
  28. +25 0 episode-302/profile-after/config/database.yml
  29. +5 0 episode-302/profile-after/config/environment.rb
  30. +30 0 episode-302/profile-after/config/environments/development.rb
  31. +60 0 episode-302/profile-after/config/environments/production.rb
  32. +39 0 episode-302/profile-after/config/environments/test.rb
  33. +7 0 episode-302/profile-after/config/initializers/backtrace_silencers.rb
  34. +10 0 episode-302/profile-after/config/initializers/inflections.rb
  35. +5 0 episode-302/profile-after/config/initializers/mime_types.rb
  36. +7 0 episode-302/profile-after/config/initializers/secret_token.rb
  37. +8 0 episode-302/profile-after/config/initializers/session_store.rb
  38. +14 0 episode-302/profile-after/config/initializers/wrap_parameters.rb
  39. +5 0 episode-302/profile-after/config/locales/en.yml
  40. +4 0 episode-302/profile-after/config/routes.rb
  41. +13 0 episode-302/profile-after/db/migrate/20111128231335_create_users.rb
  42. +26 0 episode-302/profile-after/db/schema.rb
  43. +3 0  episode-302/profile-after/db/seeds.rb
  44. +2 0  episode-302/profile-after/doc/README_FOR_APP
  45. 0  episode-302/profile-after/lib/assets/.gitkeep
  46. 0  episode-302/profile-after/lib/tasks/.gitkeep
  47. 0  episode-302/profile-after/log/.gitkeep
  48. +26 0 episode-302/profile-after/public/404.html
  49. +26 0 episode-302/profile-after/public/422.html
  50. +26 0 episode-302/profile-after/public/500.html
  51. 0  episode-302/profile-after/public/favicon.ico
  52. +5 0 episode-302/profile-after/public/robots.txt
  53. +6 0 episode-302/profile-after/script/rails
  54. 0  episode-302/profile-after/test/fixtures/.gitkeep
  55. +13 0 episode-302/profile-after/test/fixtures/users.yml
  56. 0  episode-302/profile-after/test/functional/.gitkeep
  57. +49 0 episode-302/profile-after/test/functional/users_controller_test.rb
  58. 0  episode-302/profile-after/test/integration/.gitkeep
  59. +12 0 episode-302/profile-after/test/performance/browsing_test.rb
  60. +13 0 episode-302/profile-after/test/test_helper.rb
  61. 0  episode-302/profile-after/test/unit/.gitkeep
  62. +4 0 episode-302/profile-after/test/unit/helpers/users_helper_test.rb
  63. +7 0 episode-302/profile-after/test/unit/user_test.rb
  64. 0  episode-302/profile-after/vendor/assets/stylesheets/.gitkeep
  65. 0  episode-302/profile-after/vendor/plugins/.gitkeep
  66. +15 0 episode-302/profile-before/.gitignore
  67. +17 0 episode-302/profile-before/Gemfile
  68. +118 0 episode-302/profile-before/Gemfile.lock
  69. +9 0 episode-302/profile-before/README
  70. +7 0 episode-302/profile-before/Rakefile
  71. BIN  episode-302/profile-before/app/assets/images/rails.png
  72. +9 0 episode-302/profile-before/app/assets/javascripts/application.js
  73. +3 0  episode-302/profile-before/app/assets/javascripts/users.js.coffee
  74. +85 0 episode-302/profile-before/app/assets/stylesheets/application.css
  75. +3 0  episode-302/profile-before/app/assets/stylesheets/users.css.scss
  76. +3 0  episode-302/profile-before/app/controllers/application_controller.rb
  77. +41 0 episode-302/profile-before/app/controllers/users_controller.rb
  78. +2 0  episode-302/profile-before/app/helpers/application_helper.rb
  79. +2 0  episode-302/profile-before/app/helpers/users_helper.rb
  80. 0  episode-302/profile-before/app/mailers/.gitkeep
  81. 0  episode-302/profile-before/app/models/.gitkeep
  82. +4 0 episode-302/profile-before/app/models/user.rb
  83. +17 0 episode-302/profile-before/app/views/layouts/application.html.erb
  84. +37 0 episode-302/profile-before/app/views/users/_form.html.erb
  85. +3 0  episode-302/profile-before/app/views/users/edit.html.erb
  86. +7 0 episode-302/profile-before/app/views/users/index.html.erb
  87. +5 0 episode-302/profile-before/app/views/users/new.html.erb
  88. +23 0 episode-302/profile-before/app/views/users/show.html.erb
  89. +4 0 episode-302/profile-before/config.ru
  90. +48 0 episode-302/profile-before/config/application.rb
  91. +6 0 episode-302/profile-before/config/boot.rb
  92. +25 0 episode-302/profile-before/config/database.yml
  93. +5 0 episode-302/profile-before/config/environment.rb
  94. +30 0 episode-302/profile-before/config/environments/development.rb
  95. +60 0 episode-302/profile-before/config/environments/production.rb
  96. +39 0 episode-302/profile-before/config/environments/test.rb
  97. +7 0 episode-302/profile-before/config/initializers/backtrace_silencers.rb
  98. +10 0 episode-302/profile-before/config/initializers/inflections.rb
  99. +5 0 episode-302/profile-before/config/initializers/mime_types.rb
  100. +7 0 episode-302/profile-before/config/initializers/secret_token.rb
  101. +8 0 episode-302/profile-before/config/initializers/session_store.rb
  102. +14 0 episode-302/profile-before/config/initializers/wrap_parameters.rb
  103. +5 0 episode-302/profile-before/config/locales/en.yml
  104. +4 0 episode-302/profile-before/config/routes.rb
  105. +13 0 episode-302/profile-before/db/migrate/20111128231335_create_users.rb
  106. +26 0 episode-302/profile-before/db/schema.rb
  107. +3 0  episode-302/profile-before/db/seeds.rb
  108. +2 0  episode-302/profile-before/doc/README_FOR_APP
  109. 0  episode-302/profile-before/lib/assets/.gitkeep
  110. 0  episode-302/profile-before/lib/tasks/.gitkeep
  111. 0  episode-302/profile-before/log/.gitkeep
  112. +26 0 episode-302/profile-before/public/404.html
  113. +26 0 episode-302/profile-before/public/422.html
  114. +26 0 episode-302/profile-before/public/500.html
  115. 0  episode-302/profile-before/public/favicon.ico
  116. +5 0 episode-302/profile-before/public/robots.txt
  117. +6 0 episode-302/profile-before/script/rails
  118. 0  episode-302/profile-before/test/fixtures/.gitkeep
  119. +13 0 episode-302/profile-before/test/fixtures/users.yml
  120. 0  episode-302/profile-before/test/functional/.gitkeep
  121. +49 0 episode-302/profile-before/test/functional/users_controller_test.rb
  122. 0  episode-302/profile-before/test/integration/.gitkeep
  123. +12 0 episode-302/profile-before/test/performance/browsing_test.rb
  124. +13 0 episode-302/profile-before/test/test_helper.rb
  125. 0  episode-302/profile-before/test/unit/.gitkeep
  126. +4 0 episode-302/profile-before/test/unit/helpers/users_helper_test.rb
  127. +7 0 episode-302/profile-before/test/unit/user_test.rb
  128. 0  episode-302/profile-before/vendor/assets/stylesheets/.gitkeep
  129. 0  episode-302/profile-before/vendor/plugins/.gitkeep
  130. +12 0 episode-303/README
  131. +1 0  episode-303/url_formatter
5 episode-302/README
... ... @@ -0,0 +1,5 @@
  1 +RailsCasts Episode #302: In-Place Editing
  2 +
  3 +http://railscasts.com/episodes/302-in-place-editing
  4 +
  5 +Require Ruby 1.9.2 or later to run example.
15 episode-302/profile-after/.gitignore
... ... @@ -0,0 +1,15 @@
  1 +# See http://help.github.com/ignore-files/ for more about ignoring files.
  2 +#
  3 +# If you find yourself ignoring temporary files generated by your text editor
  4 +# or operating system, you probably want to add a global ignore instead:
  5 +# git config --global core.excludesfile ~/.gitignore_global
  6 +
  7 +# Ignore bundler config
  8 +/.bundle
  9 +
  10 +# Ignore the default SQLite database.
  11 +/db/*.sqlite3
  12 +
  13 +# Ignore all logfiles and tempfiles.
  14 +/log/*.log
  15 +/tmp
18 episode-302/profile-after/Gemfile
... ... @@ -0,0 +1,18 @@
  1 +source 'http://rubygems.org'
  2 +
  3 +gem 'rails', '3.1.3'
  4 +
  5 +gem 'sqlite3'
  6 +
  7 +
  8 +# Gems used only for assets and not required
  9 +# in production environments by default.
  10 +group :assets do
  11 + gem 'sass-rails', '~> 3.1.5'
  12 + gem 'coffee-rails', '~> 3.1.1'
  13 + gem 'uglifier', '>= 1.0.3'
  14 +end
  15 +
  16 +gem 'jquery-rails'
  17 +
  18 +gem 'best_in_place'
118 episode-302/profile-after/Gemfile.lock
... ... @@ -0,0 +1,118 @@
  1 +GEM
  2 + remote: http://rubygems.org/
  3 + specs:
  4 + actionmailer (3.1.3)
  5 + actionpack (= 3.1.3)
  6 + mail (~> 2.3.0)
  7 + actionpack (3.1.3)
  8 + activemodel (= 3.1.3)
  9 + activesupport (= 3.1.3)
  10 + builder (~> 3.0.0)
  11 + erubis (~> 2.7.0)
  12 + i18n (~> 0.6)
  13 + rack (~> 1.3.5)
  14 + rack-cache (~> 1.1)
  15 + rack-mount (~> 0.8.2)
  16 + rack-test (~> 0.6.1)
  17 + sprockets (~> 2.0.3)
  18 + activemodel (3.1.3)
  19 + activesupport (= 3.1.3)
  20 + builder (~> 3.0.0)
  21 + i18n (~> 0.6)
  22 + activerecord (3.1.3)
  23 + activemodel (= 3.1.3)
  24 + activesupport (= 3.1.3)
  25 + arel (~> 2.2.1)
  26 + tzinfo (~> 0.3.29)
  27 + activeresource (3.1.3)
  28 + activemodel (= 3.1.3)
  29 + activesupport (= 3.1.3)
  30 + activesupport (3.1.3)
  31 + multi_json (~> 1.0)
  32 + arel (2.2.1)
  33 + best_in_place (1.0.2)
  34 + jquery-rails
  35 + rails (~> 3.1.0)
  36 + builder (3.0.0)
  37 + coffee-rails (3.1.1)
  38 + coffee-script (>= 2.2.0)
  39 + railties (~> 3.1.0)
  40 + coffee-script (2.2.0)
  41 + coffee-script-source
  42 + execjs
  43 + coffee-script-source (1.1.3)
  44 + erubis (2.7.0)
  45 + execjs (1.2.9)
  46 + multi_json (~> 1.0)
  47 + hike (1.2.1)
  48 + i18n (0.6.0)
  49 + jquery-rails (1.0.19)
  50 + railties (~> 3.0)
  51 + thor (~> 0.14)
  52 + json (1.6.2)
  53 + mail (2.3.0)
  54 + i18n (>= 0.4.0)
  55 + mime-types (~> 1.16)
  56 + treetop (~> 1.4.8)
  57 + mime-types (1.17.2)
  58 + multi_json (1.0.4)
  59 + polyglot (0.3.3)
  60 + rack (1.3.5)
  61 + rack-cache (1.1)
  62 + rack (>= 0.4)
  63 + rack-mount (0.8.3)
  64 + rack (>= 1.0.0)
  65 + rack-ssl (1.3.2)
  66 + rack
  67 + rack-test (0.6.1)
  68 + rack (>= 1.0)
  69 + rails (3.1.3)
  70 + actionmailer (= 3.1.3)
  71 + actionpack (= 3.1.3)
  72 + activerecord (= 3.1.3)
  73 + activeresource (= 3.1.3)
  74 + activesupport (= 3.1.3)
  75 + bundler (~> 1.0)
  76 + railties (= 3.1.3)
  77 + railties (3.1.3)
  78 + actionpack (= 3.1.3)
  79 + activesupport (= 3.1.3)
  80 + rack-ssl (~> 1.3.2)
  81 + rake (>= 0.8.7)
  82 + rdoc (~> 3.4)
  83 + thor (~> 0.14.6)
  84 + rake (0.9.2.2)
  85 + rdoc (3.11)
  86 + json (~> 1.4)
  87 + sass (3.1.11)
  88 + sass-rails (3.1.5)
  89 + actionpack (~> 3.1.0)
  90 + railties (~> 3.1.0)
  91 + sass (~> 3.1.10)
  92 + tilt (~> 1.3.2)
  93 + sprockets (2.0.3)
  94 + hike (~> 1.2)
  95 + rack (~> 1.0)
  96 + tilt (~> 1.1, != 1.3.0)
  97 + sqlite3 (1.3.4)
  98 + thor (0.14.6)
  99 + tilt (1.3.3)
  100 + treetop (1.4.10)
  101 + polyglot
  102 + polyglot (>= 0.3.1)
  103 + tzinfo (0.3.31)
  104 + uglifier (1.1.0)
  105 + execjs (>= 0.3.0)
  106 + multi_json (>= 1.0.2)
  107 +
  108 +PLATFORMS
  109 + ruby
  110 +
  111 +DEPENDENCIES
  112 + best_in_place
  113 + coffee-rails (~> 3.1.1)
  114 + jquery-rails
  115 + rails (= 3.1.3)
  116 + sass-rails (~> 3.1.5)
  117 + sqlite3
  118 + uglifier (>= 1.0.3)
9 episode-302/profile-after/README
... ... @@ -0,0 +1,9 @@
  1 += RailsCasts Example Application
  2 +
  3 +Run these commands to try it out.
  4 +
  5 + bundle
  6 + rake db:setup
  7 + rails s
  8 +
  9 +Require Ruby 1.9.2 or higher.
7 episode-302/profile-after/Rakefile
... ... @@ -0,0 +1,7 @@
  1 +#!/usr/bin/env rake
  2 +# Add your own tasks in files placed in lib/tasks ending in .rake,
  3 +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
  4 +
  5 +require File.expand_path('../config/application', __FILE__)
  6 +
  7 +Profile::Application.load_tasks
BIN  episode-302/profile-after/app/assets/images/rails.png
11 episode-302/profile-after/app/assets/javascripts/application.js
... ... @@ -0,0 +1,11 @@
  1 +// This is a manifest file that'll be compiled into including all the files listed below.
  2 +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
  3 +// be included in the compiled file accessible from http://example.com/assets/application.js
  4 +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  5 +// the compiled file.
  6 +//
  7 +//= require jquery
  8 +//= require jquery_ujs
  9 +//= require jquery.purr
  10 +//= require best_in_place
  11 +//= require_tree .
5 episode-302/profile-after/app/assets/javascripts/users.js.coffee
... ... @@ -0,0 +1,5 @@
  1 +# Place all the behaviors and hooks related to the matching controller here.
  2 +# All this logic will automatically be available in application.js.
  3 +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
  4 +jQuery ->
  5 + $('.best_in_place').best_in_place()
85 episode-302/profile-after/app/assets/stylesheets/application.css
... ... @@ -0,0 +1,85 @@
  1 +/*
  2 + * This is a manifest file that'll automatically include all the stylesheets available in this directory
  3 + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
  4 + * the top of the compiled file, but it's generally better to create a new file per style scope.
  5 + *= require_self
  6 + *= require_tree .
  7 +*/
  8 +
  9 +body {
  10 + background-color: #4B7399;
  11 + font-family: Verdana, Helvetica, Arial;
  12 + font-size: 14px;
  13 +}
  14 +
  15 +a img {
  16 + border: none;
  17 +}
  18 +
  19 +a {
  20 + color: #0000FF;
  21 +}
  22 +
  23 +.clear {
  24 + clear: both;
  25 + height: 0;
  26 + overflow: hidden;
  27 +}
  28 +
  29 +#container {
  30 + width: 75%;
  31 + margin: 0 auto;
  32 + background-color: #FFF;
  33 + padding: 20px 40px;
  34 + border: solid 1px black;
  35 + margin-top: 20px;
  36 + position: relative;
  37 +}
  38 +
  39 +#flash_notice, #flash_error, #flash_alert {
  40 + padding: 5px 8px;
  41 + margin: 10px 0;
  42 + margin-right: 150px;
  43 +}
  44 +
  45 +#flash_notice {
  46 + background-color: #CFC;
  47 + border: solid 1px #6C6;
  48 +}
  49 +
  50 +#flash_error, #flash_alert {
  51 + background-color: #FCC;
  52 + border: solid 1px #C66;
  53 +}
  54 +
  55 +.field_with_errors {
  56 + display: inline;
  57 +}
  58 +
  59 +.error_messages {
  60 + width: 400px;
  61 + border: 2px solid #CF0000;
  62 + padding: 0px;
  63 + padding-bottom: 12px;
  64 + margin-bottom: 20px;
  65 + background-color: #f0f0f0;
  66 + font-size: 12px;
  67 +}
  68 +
  69 +.error_messages h2 {
  70 + text-align: left;
  71 + font-weight: bold;
  72 + padding: 5px 10px;
  73 + font-size: 12px;
  74 + margin: 0;
  75 + background-color: #c00;
  76 + color: #fff;
  77 +}
  78 +
  79 +.error_messages p {
  80 + margin: 8px 10px;
  81 +}
  82 +
  83 +form .field, form .actions {
  84 + margin: 12px 0;
  85 +}
13 episode-302/profile-after/app/assets/stylesheets/users.css.scss
... ... @@ -0,0 +1,13 @@
  1 +// Place all the styles related to the users controller here.
  2 +// They will automatically be included in application.css.
  3 +// You can use Sass (SCSS) here: http://sass-lang.com/
  4 +.purr {
  5 + position: fixed;
  6 + top: 30px;
  7 + right: 100px;
  8 + width: 250px;
  9 + padding: 20px;
  10 + background-color: #FCC;
  11 + border: solid 2px #C66;
  12 + &:first-letter { text-transform: uppercase; }
  13 +}
3  episode-302/profile-after/app/controllers/application_controller.rb
... ... @@ -0,0 +1,3 @@
  1 +class ApplicationController < ActionController::Base
  2 + protect_from_forgery
  3 +end
40 episode-302/profile-after/app/controllers/users_controller.rb
... ... @@ -0,0 +1,40 @@
  1 +class UsersController < ApplicationController
  2 + respond_to :html, :json
  3 +
  4 + def index
  5 + @users = User.all
  6 + end
  7 +
  8 + def show
  9 + @user = User.find(params[:id])
  10 + end
  11 +
  12 + def new
  13 + @user = User.new
  14 + end
  15 +
  16 + def create
  17 + @user = User.new(params[:user])
  18 + if @user.save
  19 + redirect_to @user, notice: "Successfully created user."
  20 + else
  21 + render :new
  22 + end
  23 + end
  24 +
  25 + def edit
  26 + @user = User.find(params[:id])
  27 + end
  28 +
  29 + def update
  30 + @user = User.find(params[:id])
  31 + @user.update_attributes(params[:user])
  32 + respond_with @user
  33 + end
  34 +
  35 + def destroy
  36 + @user = User.find(params[:id])
  37 + @user.destroy
  38 + redirect_to users_url, notice: "Successfully destroyed user."
  39 + end
  40 +end
2  episode-302/profile-after/app/helpers/application_helper.rb
... ... @@ -0,0 +1,2 @@
  1 +module ApplicationHelper
  2 +end
2  episode-302/profile-after/app/helpers/users_helper.rb
... ... @@ -0,0 +1,2 @@
  1 +module UsersHelper
  2 +end
0  episode-302/profile-after/app/mailers/.gitkeep
No changes.
0  episode-302/profile-after/app/models/.gitkeep
No changes.
4 episode-302/profile-after/app/models/user.rb
... ... @@ -0,0 +1,4 @@
  1 +class User < ActiveRecord::Base
  2 + validates_presence_of :name
  3 + validates_format_of :email, with: /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
  4 +end
17 episode-302/profile-after/app/views/layouts/application.html.erb
... ... @@ -0,0 +1,17 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 + <head>
  4 + <title>Profile</title>
  5 + <%= stylesheet_link_tag "application" %>
  6 + <%= javascript_include_tag "application" %>
  7 + <%= csrf_meta_tag %>
  8 + </head>
  9 + <body>
  10 + <div id="container">
  11 + <% flash.each do |name, msg| %>
  12 + <%= content_tag :div, msg, :id => "flash_#{name}" %>
  13 + <% end %>
  14 + <%= yield %>
  15 + </div>
  16 + </body>
  17 +</html>
37 episode-302/profile-after/app/views/users/_form.html.erb
... ... @@ -0,0 +1,37 @@
  1 +<%= form_for(@user) do |f| %>
  2 + <% if @user.errors.any? %>
  3 + <div class="error_messages">
  4 + <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
  5 +
  6 + <ul>
  7 + <% @user.errors.full_messages.each do |msg| %>
  8 + <li><%= msg %></li>
  9 + <% end %>
  10 + </ul>
  11 + </div>
  12 + <% end %>
  13 +
  14 + <div class="field">
  15 + <%= f.label :name %><br />
  16 + <%= f.text_field :name %>
  17 + </div>
  18 + <div class="field">
  19 + <%= f.label :email %><br />
  20 + <%= f.text_field :email %>
  21 + </div>
  22 + <div class="field">
  23 + <%= f.label :gender %><br />
  24 + <%= f.select :gender, %w[Male Female Unspecified] %>
  25 + </div>
  26 + <div class="field">
  27 + <%= f.check_box :public_profile %>
  28 + <%= f.label :public_profile %>
  29 + </div>
  30 + <div class="field">
  31 + <%= f.label :bio %><br />
  32 + <%= f.text_area :bio %>
  33 + </div>
  34 + <div class="actions">
  35 + <%= f.submit %>
  36 + </div>
  37 +<% end %>
3  episode-302/profile-after/app/views/users/edit.html.erb
... ... @@ -0,0 +1,3 @@
  1 +<h1>Editing Profile</h1>
  2 +
  3 +<%= render 'form' %>
7 episode-302/profile-after/app/views/users/index.html.erb
... ... @@ -0,0 +1,7 @@
  1 +<h1>Users</h1>
  2 +
  3 +<ul>
  4 +<% @users.each do |user| %>
  5 + <li><%= link_to user.name, user %></li>
  6 +<% end %>
  7 +</ul>
5 episode-302/profile-after/app/views/users/new.html.erb
... ... @@ -0,0 +1,5 @@
  1 +<h1>New user</h1>
  2 +
  3 +<%= render 'form' %>
  4 +
  5 +<%= link_to 'Back', users_path %>
23 episode-302/profile-after/app/views/users/show.html.erb
... ... @@ -0,0 +1,23 @@
  1 +<h1>User Profile</h1>
  2 +
  3 +<p>
  4 + <b>Name:</b>
  5 + <%= best_in_place @user, :name %>
  6 +</p>
  7 +<p>
  8 + <b>Email:</b>
  9 + <%= best_in_place @user, :email %>
  10 +</p>
  11 +<p>
  12 + <b>Gender:</b>
  13 + <%= best_in_place @user, :gender, type: :select, collection: [["Male", "Male"], ["Female", "Female"], ["", "Unspecified"]] %>
  14 +</p>
  15 +<p>
  16 + <b>Public profile:</b>
  17 + <%= best_in_place @user, :public_profile, type: :checkbox, collection: %w[No Yes] %>
  18 +</p>
  19 +<p>
  20 + <%= best_in_place @user, :bio, type: :textarea %>
  21 +</p>
  22 +
  23 +<%= link_to 'Edit Profile', edit_user_path(@user) %>
4 episode-302/profile-after/config.ru
... ... @@ -0,0 +1,4 @@
  1 +# This file is used by Rack-based servers to start the application.
  2 +
  3 +require ::File.expand_path('../config/environment', __FILE__)
  4 +run Profile::Application
48 episode-302/profile-after/config/application.rb
... ... @@ -0,0 +1,48 @@
  1 +require File.expand_path('../boot', __FILE__)
  2 +
  3 +require 'rails/all'
  4 +
  5 +if defined?(Bundler)
  6 + # If you precompile assets before deploying to production, use this line
  7 + Bundler.require(*Rails.groups(:assets => %w(development test)))
  8 + # If you want your assets lazily compiled in production, use this line
  9 + # Bundler.require(:default, :assets, Rails.env)
  10 +end
  11 +
  12 +module Profile
  13 + class Application < Rails::Application
  14 + # Settings in config/environments/* take precedence over those specified here.
  15 + # Application configuration should go into files in config/initializers
  16 + # -- all .rb files in that directory are automatically loaded.
  17 +
  18 + # Custom directories with classes and modules you want to be autoloadable.
  19 + # config.autoload_paths += %W(#{config.root}/extras)
  20 +
  21 + # Only load the plugins named here, in the order given (default is alphabetical).
  22 + # :all can be used as a placeholder for all plugins not explicitly named.
  23 + # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
  24 +
  25 + # Activate observers that should always be running.
  26 + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
  27 +
  28 + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  29 + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  30 + # config.time_zone = 'Central Time (US & Canada)'
  31 +
  32 + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
  33 + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  34 + # config.i18n.default_locale = :de
  35 +
  36 + # Configure the default encoding used in templates for Ruby 1.9.
  37 + config.encoding = "utf-8"
  38 +
  39 + # Configure sensitive parameters which will be filtered from the log file.
  40 + config.filter_parameters += [:password]
  41 +
  42 + # Enable the asset pipeline
  43 + config.assets.enabled = true
  44 +
  45 + # Version of your assets, change this if you want to expire all your assets
  46 + config.assets.version = '1.0'
  47 + end
  48 +end
6 episode-302/profile-after/config/boot.rb
... ... @@ -0,0 +1,6 @@
  1 +require 'rubygems'
  2 +
  3 +# Set up gems listed in the Gemfile.
  4 +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
  5 +
  6 +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
25 episode-302/profile-after/config/database.yml
... ... @@ -0,0 +1,25 @@
  1 +# SQLite version 3.x
  2 +# gem install sqlite3
  3 +#
  4 +# Ensure the SQLite 3 gem is defined in your Gemfile
  5 +# gem 'sqlite3'
  6 +development:
  7 + adapter: sqlite3
  8 + database: db/development.sqlite3
  9 + pool: 5
  10 + timeout: 5000
  11 +
  12 +# Warning: The database defined as "test" will be erased and
  13 +# re-generated from your development database when you run "rake".
  14 +# Do not set this db to the same as development or production.
  15 +test:
  16 + adapter: sqlite3
  17 + database: db/test.sqlite3
  18 + pool: 5
  19 + timeout: 5000
  20 +
  21 +production:
  22 + adapter: sqlite3
  23 + database: db/production.sqlite3
  24 + pool: 5
  25 + timeout: 5000
5 episode-302/profile-after/config/environment.rb
... ... @@ -0,0 +1,5 @@
  1 +# Load the rails application
  2 +require File.expand_path('../application', __FILE__)
  3 +
  4 +# Initialize the rails application
  5 +Profile::Application.initialize!
30 episode-302/profile-after/config/environments/development.rb
... ... @@ -0,0 +1,30 @@
  1 +Profile::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # In the development environment your application's code is reloaded on
  5 + # every request. This slows down response time but is perfect for development
  6 + # since you don't have to restart the web server when you make code changes.
  7 + config.cache_classes = false
  8 +
  9 + # Log error messages when you accidentally call methods on nil.
  10 + config.whiny_nils = true
  11 +
  12 + # Show full error reports and disable caching
  13 + config.consider_all_requests_local = true
  14 + config.action_controller.perform_caching = false
  15 +
  16 + # Don't care if the mailer can't send
  17 + config.action_mailer.raise_delivery_errors = false
  18 +
  19 + # Print deprecation notices to the Rails logger
  20 + config.active_support.deprecation = :log
  21 +
  22 + # Only use best-standards-support built into browsers
  23 + config.action_dispatch.best_standards_support = :builtin
  24 +
  25 + # Do not compress assets
  26 + config.assets.compress = false
  27 +
  28 + # Expands the lines which load the assets
  29 + config.assets.debug = true
  30 +end
60 episode-302/profile-after/config/environments/production.rb
... ... @@ -0,0 +1,60 @@
  1 +Profile::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # Code is not reloaded between requests
  5 + config.cache_classes = true
  6 +
  7 + # Full error reports are disabled and caching is turned on
  8 + config.consider_all_requests_local = false
  9 + config.action_controller.perform_caching = true
  10 +
  11 + # Disable Rails's static asset server (Apache or nginx will already do this)
  12 + config.serve_static_assets = false
  13 +
  14 + # Compress JavaScripts and CSS
  15 + config.assets.compress = true
  16 +
  17 + # Don't fallback to assets pipeline if a precompiled asset is missed
  18 + config.assets.compile = false
  19 +
  20 + # Generate digests for assets URLs
  21 + config.assets.digest = true
  22 +
  23 + # Defaults to Rails.root.join("public/assets")
  24 + # config.assets.manifest = YOUR_PATH
  25 +
  26 + # Specifies the header that your server uses for sending files
  27 + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  28 + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
  29 +
  30 + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  31 + # config.force_ssl = true
  32 +
  33 + # See everything in the log (default is :info)
  34 + # config.log_level = :debug
  35 +
  36 + # Use a different logger for distributed setups
  37 + # config.logger = SyslogLogger.new
  38 +
  39 + # Use a different cache store in production
  40 + # config.cache_store = :mem_cache_store
  41 +
  42 + # Enable serving of images, stylesheets, and JavaScripts from an asset server
  43 + # config.action_controller.asset_host = "http://assets.example.com"
  44 +
  45 + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  46 + # config.assets.precompile += %w( search.js )
  47 +
  48 + # Disable delivery errors, bad email addresses will be ignored
  49 + # config.action_mailer.raise_delivery_errors = false
  50 +
  51 + # Enable threaded mode
  52 + # config.threadsafe!
  53 +
  54 + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  55 + # the I18n.default_locale when a translation can not be found)
  56 + config.i18n.fallbacks = true
  57 +
  58 + # Send deprecation notices to registered listeners
  59 + config.active_support.deprecation = :notify
  60 +end
39 episode-302/profile-after/config/environments/test.rb
... ... @@ -0,0 +1,39 @@
  1 +Profile::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
  3 +
  4 + # The test environment is used exclusively to run your application's
  5 + # test suite. You never need to work with it otherwise. Remember that
  6 + # your test database is "scratch space" for the test suite and is wiped
  7 + # and recreated between test runs. Don't rely on the data there!
  8 + config.cache_classes = true
  9 +
  10 + # Configure static asset server for tests with Cache-Control for performance
  11 + config.serve_static_assets = true
  12 + config.static_cache_control = "public, max-age=3600"
  13 +
  14 + # Log error messages when you accidentally call methods on nil
  15 + config.whiny_nils = true
  16 +
  17 + # Show full error reports and disable caching
  18 + config.consider_all_requests_local = true
  19 + config.action_controller.perform_caching = false
  20 +
  21 + # Raise exceptions instead of rendering exception templates
  22 + config.action_dispatch.show_exceptions = false
  23 +
  24 + # Disable request forgery protection in test environment
  25 + config.action_controller.allow_forgery_protection = false
  26 +
  27 + # Tell Action Mailer not to deliver emails to the real world.
  28 + # The :test delivery method accumulates sent emails in the
  29 + # ActionMailer::Base.deliveries array.
  30 + config.action_mailer.delivery_method = :test
  31 +
  32 + # Use SQL instead of Active Record's schema dumper when creating the test database.
  33 + # This is necessary if your schema can't be completely dumped by the schema dumper,
  34 + # like if you have constraints or database-specific column types
  35 + # config.active_record.schema_format = :sql
  36 +
  37 + # Print deprecation notices to the stderr
  38 + config.active_support.deprecation = :stderr
  39 +end
7 episode-302/profile-after/config/initializers/backtrace_silencers.rb
... ... @@ -0,0 +1,7 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  4 +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
  5 +
  6 +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
  7 +# Rails.backtrace_cleaner.remove_silencers!
10 episode-302/profile-after/config/initializers/inflections.rb
... ... @@ -0,0 +1,10 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Add new inflection rules using the following format
  4 +# (all these examples are active by default):
  5 +# ActiveSupport::Inflector.inflections do |inflect|
  6 +# inflect.plural /^(ox)$/i, '\1en'
  7 +# inflect.singular /^(ox)en/i, '\1'
  8 +# inflect.irregular 'person', 'people'
  9 +# inflect.uncountable %w( fish sheep )
  10 +# end
5 episode-302/profile-after/config/initializers/mime_types.rb
... ... @@ -0,0 +1,5 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Add new mime types for use in respond_to blocks:
  4 +# Mime::Type.register "text/richtext", :rtf
  5 +# Mime::Type.register_alias "text/html", :iphone
7 episode-302/profile-after/config/initializers/secret_token.rb
... ... @@ -0,0 +1,7 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +# Your secret key for verifying the integrity of signed cookies.
  4 +# If you change this key, all old signed cookies will become invalid!
  5 +# Make sure the secret is at least 30 characters and all random,
  6 +# no regular words or you'll be exposed to dictionary attacks.
  7 +Profile::Application.config.secret_token = '67a1af5d3de2b39a29327164e55de21ba0faff390e37b155d9c2cd48001ca86245bfc34b9f58937574506428a8a9b2b9645988a670e648357d338828e6d09654'
8 episode-302/profile-after/config/initializers/session_store.rb
... ... @@ -0,0 +1,8 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +
  3 +Profile::Application.config.session_store :cookie_store, key: '_profile_session'
  4 +
  5 +# Use the database for sessions instead of the cookie-based default,
  6 +# which shouldn't be used to store highly confidential information
  7 +# (create the session table with "rails generate session_migration")
  8 +# Profile::Application.config.session_store :active_record_store
14 episode-302/profile-after/config/initializers/wrap_parameters.rb
... ... @@ -0,0 +1,14 @@
  1 +# Be sure to restart your server when you modify this file.
  2 +#
  3 +# This file contains settings for ActionController::ParamsWrapper which
  4 +# is enabled by default.
  5 +
  6 +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
  7 +ActiveSupport.on_load(:action_controller) do
  8 + wrap_parameters format: [:json]
  9 +end
  10 +
  11 +# Disable root element in JSON by default.
  12 +ActiveSupport.on_load(:active_record) do
  13 + self.include_root_in_json = false
  14 +end
5 episode-302/profile-after/config/locales/en.yml
... ... @@ -0,0 +1,5 @@
  1 +# Sample localization file for English. Add more files in this directory for other locales.
  2 +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
  3 +
  4 +en:
  5 + hello: "Hello world"
4 episode-302/profile-after/config/routes.rb
... ... @@ -0,0 +1,4 @@
  1 +Profile::Application.routes.draw do
  2 + root to: 'users#index'
  3 + resources :users
  4 +end
13 episode-302/profile-after/db/migrate/20111128231335_create_users.rb
... ... @@ -0,0 +1,13 @@
  1 +class CreateUsers < ActiveRecord::Migration
  2 + def change
  3 + create_table :users do |t|
  4 + t.string :name
  5 + t.string :email
  6 + t.string :gender
  7 + t.text :bio
  8 + t.boolean :public_profile
  9 +
  10 + t.timestamps
  11 + end
  12 + end
  13 +end
26 episode-302/profile-after/db/schema.rb
... ... @@ -0,0 +1,26 @@
  1 +# encoding: UTF-8
  2 +# This file is auto-generated from the current state of the database. Instead
  3 +# of editing this file, please use the migrations feature of Active Record to
  4 +# incrementally modify your database, and then regenerate this schema definition.
  5 +#
  6 +# Note that this schema.rb definition is the authoritative source for your
  7 +# database schema. If you need to create the application database on another
  8 +# system, you should be using db:schema:load, not running all the migrations
  9 +# from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10 +# you'll amass, the slower it'll run and the greater likelihood for issues).
  11 +#
  12 +# It's strongly recommended to check this file into your version control system.
  13 +
  14 +ActiveRecord::Schema.define(:version => 20111128231335) do
  15 +
  16 + create_table "users", :force => true do |t|
  17 + t.string "name"
  18 + t.string "email"
  19 + t.string "gender"
  20 + t.text "bio"
  21 + t.boolean "public_profile"
  22 + t.datetime "created_at"
  23 + t.datetime "updated_at"
  24 + end
  25 +
  26 +end
3  episode-302/profile-after/db/seeds.rb
... ... @@ -0,0 +1,3 @@
  1 +User.create! name: "Batman", email: "batman@example.com", gender: "Male", public_profile: true, bio: <<-BIO
  2 +The Dark Knight is dedicated to ridding Gotham of evil. Complete with his cape, utility belt, and bullet proof suite, no criminal has a chance against this Caped Crusader.
  3 +BIO
2  episode-302/profile-after/doc/README_FOR_APP
... ... @@ -0,0 +1,2 @@
  1 +Use this README file to introduce your application and point to useful places in the API for learning more.
  2 +Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0  episode-302/profile-after/lib/assets/.gitkeep
No changes.
0  episode-302/profile-after/lib/tasks/.gitkeep
No changes.
0  episode-302/profile-after/log/.gitkeep
No changes.
26 episode-302/profile-after/public/404.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>The page you were looking for doesn't exist (404)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/404.html -->
  21 + <div class="dialog">
  22 + <h1>The page you were looking for doesn't exist.</h1>
  23 + <p>You may have mistyped the address or the page may have moved.</p>
  24 + </div>
  25 +</body>
  26 +</html>
26 episode-302/profile-after/public/422.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>The change you wanted was rejected (422)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/422.html -->
  21 + <div class="dialog">
  22 + <h1>The change you wanted was rejected.</h1>
  23 + <p>Maybe you tried to change something you didn't have access to.</p>
  24 + </div>
  25 +</body>
  26 +</html>
26 episode-302/profile-after/public/500.html
... ... @@ -0,0 +1,26 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>We're sorry, but something went wrong (500)</title>
  5 + <style type="text/css">
  6 + body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
  7 + div.dialog {
  8 + width: 25em;
  9 + padding: 0 4em;
  10 + margin: 4em auto 0 auto;
  11 + border: 1px solid #ccc;
  12 + border-right-color: #999;
  13 + border-bottom-color: #999;
  14 + }
  15 + h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  16 + </style>
  17 +</head>
  18 +
  19 +<body>
  20 + <!-- This file lives in public/500.html -->
  21 + <div class="dialog">
  22 + <h1>We're sorry, but something went wrong.</h1>
  23 + <p>We've been notified about this issue and we'll take a look at it shortly.</p>
  24 + </div>
  25 +</body>
  26 +</html>
0  episode-302/profile-after/public/favicon.ico
No changes.
5 episode-302/profile-after/public/robots.txt
... ... @@ -0,0 +1,5 @@
  1 +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
  2 +#
  3 +# To ban all spiders from the entire site uncomment the next two lines:
  4 +# User-Agent: *
  5 +# Disallow: /
6 episode-302/profile-after/script/rails
... ... @@ -0,0 +1,6 @@
  1 +#!/usr/bin/env ruby
  2 +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
  3 +
  4 +APP_PATH = File.expand_path('../../config/application', __FILE__)
  5 +require File.expand_path('../../config/boot', __FILE__)
  6 +require 'rails/commands'
0  episode-302/profile-after/test/fixtures/.gitkeep
No changes.
13 episode-302/profile-after/test/fixtures/users.yml
... ... @@ -0,0 +1,13 @@
  1 +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
  2 +
  3 +one:
  4 + name: MyString
  5 + gender: MyString
  6 + bio: MyText
  7 + public_profile: false
  8 +
  9 +two:
  10 + name: MyString
  11 + gender: MyString
  12 + bio: MyText
  13 + public_profile: false
0  episode-302/profile-after/test/functional/.gitkeep
No changes.
49 episode-302/profile-after/test/functional/users_controller_test.rb
... ... @@ -0,0 +1,49 @@
  1 +require 'test_helper'
  2 +
  3 +class UsersControllerTest < ActionController::TestCase
  4 + setup do
  5 + @user = users(:one)
  6 + end
  7 +
  8 + test "should get index" do
  9 + get :index
  10 + assert_response :success
  11 + assert_not_nil assigns(:users)
  12 + end
  13 +
  14 + test "should get new" do
  15 + get :new
  16 + assert_response :success
  17 + end
  18 +
  19 + test "should create user" do
  20 + assert_difference('User.count') do
  21 + post :create, user: @user.attributes
  22 + end
  23 +
  24 + assert_redirected_to user_path(assigns(:user))
  25 + end
  26 +
  27 + test "should show user" do
  28 + get :show, id: @user.to_param
  29 + assert_response :success
  30 + end
  31 +
  32 + test "should get edit" do
  33 + get :edit, id: @user.to_param
  34 + assert_response :success
  35 + end
  36 +
  37 + test "should update user" do
  38 + put :update, id: @user.to_param, user: @user.attributes
  39 + assert_redirected_to user_path(assigns(:user))
  40 + end
  41 +
  42 + test "should destroy user" do
  43 + assert_difference('User.count', -1) do
  44 + delete :destroy, id: @user.to_param