Permalink
Browse files

adding episode 286

  • Loading branch information...
1 parent 0499698 commit 8d934487550cc247fb83cc1d5300388578c91f51 @ryanb committed Oct 3, 2011
Showing with 2,106 additions and 0 deletions.
  1. +8 −0 episode-286/README
  2. +5 −0 episode-286/profile-after/.gitignore
  3. +17 −0 episode-286/profile-after/Gemfile
  4. +119 −0 episode-286/profile-after/Gemfile.lock
  5. +7 −0 episode-286/profile-after/README
  6. +7 −0 episode-286/profile-after/Rakefile
  7. BIN episode-286/profile-after/app/assets/images/avatars/default.png
  8. BIN episode-286/profile-after/app/assets/images/avatars/ryan.png
  9. BIN episode-286/profile-after/app/assets/images/rails.png
  10. +9 −0 episode-286/profile-after/app/assets/javascripts/application.js
  11. +3 −0 episode-286/profile-after/app/assets/javascripts/users.js.coffee
  12. +96 −0 episode-286/profile-after/app/assets/stylesheets/application.css
  13. +41 −0 episode-286/profile-after/app/assets/stylesheets/users.css.scss
  14. +3 −0 episode-286/profile-after/app/controllers/application_controller.rb
  15. +9 −0 episode-286/profile-after/app/controllers/users_controller.rb
  16. +32 −0 episode-286/profile-after/app/decorators/application_decorator.rb
  17. +85 −0 episode-286/profile-after/app/decorators/user_decorator.rb
  18. +2 −0 episode-286/profile-after/app/helpers/application_helper.rb
  19. +2 −0 episode-286/profile-after/app/helpers/users_helper.rb
  20. 0 episode-286/profile-after/app/mailers/.gitkeep
  21. 0 episode-286/profile-after/app/models/.gitkeep
  22. +2 −0 episode-286/profile-after/app/models/user.rb
  23. +17 −0 episode-286/profile-after/app/views/layouts/application.html.erb
  24. +45 −0 episode-286/profile-after/app/views/users/_form.html.erb
  25. +6 −0 episode-286/profile-after/app/views/users/edit.html.erb
  26. +7 −0 episode-286/profile-after/app/views/users/index.html.erb
  27. +5 −0 episode-286/profile-after/app/views/users/new.html.erb
  28. +34 −0 episode-286/profile-after/app/views/users/show-before.html.erb
  29. +16 −0 episode-286/profile-after/app/views/users/show.html.erb
  30. +4 −0 episode-286/profile-after/config.ru
  31. +48 −0 episode-286/profile-after/config/application.rb
  32. +6 −0 episode-286/profile-after/config/boot.rb
  33. +25 −0 episode-286/profile-after/config/database.yml
  34. +5 −0 episode-286/profile-after/config/environment.rb
  35. +30 −0 episode-286/profile-after/config/environments/development.rb
  36. +60 −0 episode-286/profile-after/config/environments/production.rb
  37. +42 −0 episode-286/profile-after/config/environments/test.rb
  38. +7 −0 episode-286/profile-after/config/initializers/backtrace_silencers.rb
  39. +10 −0 episode-286/profile-after/config/initializers/inflections.rb
  40. +5 −0 episode-286/profile-after/config/initializers/mime_types.rb
  41. +7 −0 episode-286/profile-after/config/initializers/secret_token.rb
  42. +8 −0 episode-286/profile-after/config/initializers/session_store.rb
  43. +14 −0 episode-286/profile-after/config/initializers/wrap_parameters.rb
  44. +5 −0 episode-286/profile-after/config/locales/en.yml
  45. +4 −0 episode-286/profile-after/config/routes.rb
  46. +15 −0 episode-286/profile-after/db/migrate/20110929172314_create_users.rb
  47. +28 −0 episode-286/profile-after/db/schema.rb
  48. +25 −0 episode-286/profile-after/db/seeds.rb
  49. +2 −0 episode-286/profile-after/doc/README_FOR_APP
  50. 0 episode-286/profile-after/lib/assets/.gitkeep
  51. 0 episode-286/profile-after/lib/tasks/.gitkeep
  52. 0 episode-286/profile-after/log/.gitkeep
  53. +26 −0 episode-286/profile-after/public/404.html
  54. +26 −0 episode-286/profile-after/public/422.html
  55. +26 −0 episode-286/profile-after/public/500.html
  56. 0 episode-286/profile-after/public/favicon.ico
  57. +5 −0 episode-286/profile-after/public/robots.txt
  58. +6 −0 episode-286/profile-after/script/rails
  59. 0 episode-286/profile-after/test/fixtures/.gitkeep
  60. +19 −0 episode-286/profile-after/test/fixtures/users.yml
  61. 0 episode-286/profile-after/test/functional/.gitkeep
  62. +49 −0 episode-286/profile-after/test/functional/users_controller_test.rb
  63. 0 episode-286/profile-after/test/integration/.gitkeep
  64. +12 −0 episode-286/profile-after/test/performance/browsing_test.rb
  65. +13 −0 episode-286/profile-after/test/test_helper.rb
  66. 0 episode-286/profile-after/test/unit/.gitkeep
  67. +4 −0 episode-286/profile-after/test/unit/helpers/users_helper_test.rb
  68. +7 −0 episode-286/profile-after/test/unit/user_test.rb
  69. 0 episode-286/profile-after/vendor/assets/stylesheets/.gitkeep
  70. 0 episode-286/profile-after/vendor/plugins/.gitkeep
  71. +5 −0 episode-286/profile-before/.gitignore
  72. +16 −0 episode-286/profile-before/Gemfile
  73. +117 −0 episode-286/profile-before/Gemfile.lock
  74. +7 −0 episode-286/profile-before/README
  75. +7 −0 episode-286/profile-before/Rakefile
  76. BIN episode-286/profile-before/app/assets/images/avatars/default.png
  77. BIN episode-286/profile-before/app/assets/images/avatars/ryan.png
  78. BIN episode-286/profile-before/app/assets/images/rails.png
  79. +9 −0 episode-286/profile-before/app/assets/javascripts/application.js
  80. +3 −0 episode-286/profile-before/app/assets/javascripts/users.js.coffee
  81. +96 −0 episode-286/profile-before/app/assets/stylesheets/application.css
  82. +41 −0 episode-286/profile-before/app/assets/stylesheets/users.css.scss
  83. +3 −0 episode-286/profile-before/app/controllers/application_controller.rb
  84. +9 −0 episode-286/profile-before/app/controllers/users_controller.rb
  85. +2 −0 episode-286/profile-before/app/helpers/application_helper.rb
  86. +9 −0 episode-286/profile-before/app/helpers/users_helper.rb
  87. 0 episode-286/profile-before/app/mailers/.gitkeep
  88. 0 episode-286/profile-before/app/models/.gitkeep
  89. +5 −0 episode-286/profile-before/app/models/user.rb
  90. +17 −0 episode-286/profile-before/app/views/layouts/application.html.erb
  91. +45 −0 episode-286/profile-before/app/views/users/_form.html.erb
  92. +6 −0 episode-286/profile-before/app/views/users/edit.html.erb
  93. +7 −0 episode-286/profile-before/app/views/users/index.html.erb
  94. +5 −0 episode-286/profile-before/app/views/users/new.html.erb
  95. +34 −0 episode-286/profile-before/app/views/users/show.html.erb
  96. +4 −0 episode-286/profile-before/config.ru
  97. +48 −0 episode-286/profile-before/config/application.rb
  98. +6 −0 episode-286/profile-before/config/boot.rb
  99. +25 −0 episode-286/profile-before/config/database.yml
  100. +5 −0 episode-286/profile-before/config/environment.rb
  101. +30 −0 episode-286/profile-before/config/environments/development.rb
  102. +60 −0 episode-286/profile-before/config/environments/production.rb
  103. +42 −0 episode-286/profile-before/config/environments/test.rb
  104. +7 −0 episode-286/profile-before/config/initializers/backtrace_silencers.rb
  105. +10 −0 episode-286/profile-before/config/initializers/inflections.rb
  106. +5 −0 episode-286/profile-before/config/initializers/mime_types.rb
  107. +7 −0 episode-286/profile-before/config/initializers/secret_token.rb
  108. +8 −0 episode-286/profile-before/config/initializers/session_store.rb
  109. +14 −0 episode-286/profile-before/config/initializers/wrap_parameters.rb
  110. +5 −0 episode-286/profile-before/config/locales/en.yml
  111. +4 −0 episode-286/profile-before/config/routes.rb
  112. +15 −0 episode-286/profile-before/db/migrate/20110929172314_create_users.rb
  113. +28 −0 episode-286/profile-before/db/schema.rb
  114. +25 −0 episode-286/profile-before/db/seeds.rb
  115. +2 −0 episode-286/profile-before/doc/README_FOR_APP
  116. 0 episode-286/profile-before/lib/assets/.gitkeep
  117. 0 episode-286/profile-before/lib/tasks/.gitkeep
  118. 0 episode-286/profile-before/log/.gitkeep
  119. +26 −0 episode-286/profile-before/public/404.html
  120. +26 −0 episode-286/profile-before/public/422.html
  121. +26 −0 episode-286/profile-before/public/500.html
  122. 0 episode-286/profile-before/public/favicon.ico
  123. +5 −0 episode-286/profile-before/public/robots.txt
  124. +6 −0 episode-286/profile-before/script/rails
  125. 0 episode-286/profile-before/test/fixtures/.gitkeep
  126. +19 −0 episode-286/profile-before/test/fixtures/users.yml
  127. 0 episode-286/profile-before/test/functional/.gitkeep
  128. +49 −0 episode-286/profile-before/test/functional/users_controller_test.rb
  129. 0 episode-286/profile-before/test/integration/.gitkeep
  130. +12 −0 episode-286/profile-before/test/performance/browsing_test.rb
  131. +13 −0 episode-286/profile-before/test/test_helper.rb
  132. 0 episode-286/profile-before/test/unit/.gitkeep
  133. +4 −0 episode-286/profile-before/test/unit/helpers/users_helper_test.rb
  134. +7 −0 episode-286/profile-before/test/unit/user_test.rb
  135. 0 episode-286/profile-before/vendor/assets/stylesheets/.gitkeep
  136. 0 episode-286/profile-before/vendor/plugins/.gitkeep
View
@@ -0,0 +1,8 @@
+RailsCasts Episode #286: Draper
+
+http://railscasts.com/episodes/286-draper
+
+Commands used in episode
+
+ bundle
+ rails g draper:decorator user
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0'
+gem 'sqlite3'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', " ~> 3.1.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
+gem 'redcarpet'
+
+gem 'draper'
@@ -0,0 +1,119 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
+ mail (~> 2.3.0)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.0.3)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ bcrypt-ruby (~> 3.0.0)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.1)
+ builder (3.0.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ draper (0.7.3)
+ erubis (2.7.0)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.14)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ polyglot (0.3.2)
+ rack (1.3.3)
+ rack-cache (1.0.3)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
+ bundler (~> 1.0)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ redcarpet (1.17.2)
+ sass (3.1.7)
+ sass-rails (3.1.3)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sprockets (~> 2.0.0)
+ tilt (~> 1.3.2)
+ sprockets (2.0.0)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.29)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.0)
+ draper
+ jquery-rails
+ rails (= 3.1.0)
+ redcarpet
+ sass-rails (~> 3.1.0)
+ sqlite3
+ uglifier
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
@@ -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__)
+
+Profile::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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 .
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,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;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.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;
+}
@@ -0,0 +1,41 @@
+#profile {
+ .avatar {
+ float: left;
+ margin-left: 58px;
+ border: solid 1px #999;
+ }
+
+ h1 {
+ font-size: 40px;
+ margin-left: 175px;
+ padding-top: 28px;
+ a { color: #000; }
+ }
+
+ dl {
+ clear: both;
+ }
+
+ dt {
+ float: left;
+ font-weight: bold;
+ text-align: right;
+ width: 160px;
+ }
+
+ dd {
+ margin-left: 175px;
+ }
+
+ dd p:first-child {
+ margin-top: 0;
+ }
+
+ dd, dt {
+ padding-top: 20px;
+ }
+
+ .none {
+ color: #999;
+ }
+}
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,9 @@
+class UsersController < ApplicationController
+ def index
+ @users = User.all
+ end
+
+ def show
+ @user = UserDecorator.find(params[:id])
+ end
+end
@@ -0,0 +1,32 @@
+class ApplicationDecorator < Draper::Base
+ def markdown(text)
+ Redcarpet.new(text, :hard_wrap, :filter_html, :autolink).to_html.html_safe
+ end
+
+ # Lazy Helpers
+ # PRO: Call Rails helpers without the h. proxy
+ # ex: number_to_currency(model.price)
+ # CON: Add a bazillion methods into your decorator's namespace
+ # and probably sacrifice performance/memory
+ #
+ # Enable them by uncommenting this line:
+ # lazy_helpers
+
+ # Shared Decorations
+ # Consider defining shared methods common to all your models.
+ #
+ # Example: standardize the formatting of timestamps
+ #
+ # def formatted_timestamp(time)
+ # h.content_tag :span, time.strftime("%a %m/%d/%y"),
+ # :class => 'timestamp'
+ # end
+ #
+ # def created_at
+ # formatted_timestamp(model.created_at)
+ # end
+ #
+ # def updated_at
+ # formatted_timestamp(model.updated_at)
+ # end
+end
Oops, something went wrong.

0 comments on commit 8d93448

Please sign in to comment.