Permalink
Browse files

adding revised episode 171

  • Loading branch information...
1 parent 92133d1 commit 457b96b02d739e9990775011c27e4bf3da2e6650 @ryanb committed Jan 8, 2012
Showing with 1,776 additions and 0 deletions.
  1. +13 −0 episode-171/revised/README
  2. +15 −0 episode-171/revised/mailit-after/.gitignore
  3. +19 −0 episode-171/revised/mailit-after/Gemfile
  4. +136 −0 episode-171/revised/mailit-after/Gemfile.lock
  5. +9 −0 episode-171/revised/mailit-after/README
  6. +7 −0 episode-171/revised/mailit-after/Rakefile
  7. BIN episode-171/revised/mailit-after/app/assets/images/rails.png
  8. +9 −0 episode-171/revised/mailit-after/app/assets/javascripts/application.js
  9. +3 −0 episode-171/revised/mailit-after/app/assets/javascripts/newsletters.js.coffee
  10. +87 −0 episode-171/revised/mailit-after/app/assets/stylesheets/application.css
  11. +3 −0 episode-171/revised/mailit-after/app/assets/stylesheets/newsletters.css.scss
  12. +3 −0 episode-171/revised/mailit-after/app/controllers/application_controller.rb
  13. +46 −0 episode-171/revised/mailit-after/app/controllers/newsletters_controller.rb
  14. +2 −0 episode-171/revised/mailit-after/app/helpers/application_helper.rb
  15. +2 −0 episode-171/revised/mailit-after/app/helpers/newsletters_helper.rb
  16. 0 episode-171/revised/mailit-after/app/mailers/.gitkeep
  17. 0 episode-171/revised/mailit-after/app/models/.gitkeep
  18. +10 −0 episode-171/revised/mailit-after/app/models/newsletter.rb
  19. +18 −0 episode-171/revised/mailit-after/app/views/layouts/application.html.erb
  20. +19 −0 episode-171/revised/mailit-after/app/views/newsletters/_form.html.erb
  21. +6 −0 episode-171/revised/mailit-after/app/views/newsletters/edit.html.erb
  22. +14 −0 episode-171/revised/mailit-after/app/views/newsletters/index.html.erb
  23. +5 −0 episode-171/revised/mailit-after/app/views/newsletters/new.html.erb
  24. +15 −0 episode-171/revised/mailit-after/app/views/newsletters/show.html.erb
  25. +4 −0 episode-171/revised/mailit-after/config.ru
  26. +48 −0 episode-171/revised/mailit-after/config/application.rb
  27. +6 −0 episode-171/revised/mailit-after/config/boot.rb
  28. +25 −0 episode-171/revised/mailit-after/config/database.yml
  29. +5 −0 episode-171/revised/mailit-after/config/environment.rb
  30. +30 −0 episode-171/revised/mailit-after/config/environments/development.rb
  31. +60 −0 episode-171/revised/mailit-after/config/environments/production.rb
  32. +39 −0 episode-171/revised/mailit-after/config/environments/test.rb
  33. +7 −0 episode-171/revised/mailit-after/config/initializers/backtrace_silencers.rb
  34. +2 −0 episode-171/revised/mailit-after/config/initializers/delayed_job_config.rb
  35. +10 −0 episode-171/revised/mailit-after/config/initializers/inflections.rb
  36. +5 −0 episode-171/revised/mailit-after/config/initializers/mime_types.rb
  37. +7 −0 episode-171/revised/mailit-after/config/initializers/secret_token.rb
  38. +8 −0 episode-171/revised/mailit-after/config/initializers/session_store.rb
  39. +14 −0 episode-171/revised/mailit-after/config/initializers/wrap_parameters.rb
  40. +5 −0 episode-171/revised/mailit-after/config/locales/en.yml
  41. +7 −0 episode-171/revised/mailit-after/config/routes.rb
  42. +10 −0 episode-171/revised/mailit-after/db/migrate/20120107211315_create_newsletters.rb
  43. +22 −0 episode-171/revised/mailit-after/db/migrate/20120107222055_create_delayed_jobs.rb
  44. +46 −0 episode-171/revised/mailit-after/db/schema.rb
  45. +4 −0 episode-171/revised/mailit-after/db/seeds.rb
  46. +2 −0 episode-171/revised/mailit-after/doc/README_FOR_APP
  47. 0 episode-171/revised/mailit-after/lib/assets/.gitkeep
  48. 0 episode-171/revised/mailit-after/lib/tasks/.gitkeep
  49. 0 episode-171/revised/mailit-after/log/.gitkeep
  50. +26 −0 episode-171/revised/mailit-after/public/404.html
  51. +26 −0 episode-171/revised/mailit-after/public/422.html
  52. +26 −0 episode-171/revised/mailit-after/public/500.html
  53. 0 episode-171/revised/mailit-after/public/favicon.ico
  54. +5 −0 episode-171/revised/mailit-after/public/robots.txt
  55. +5 −0 episode-171/revised/mailit-after/script/delayed_job
  56. +6 −0 episode-171/revised/mailit-after/script/rails
  57. 0 episode-171/revised/mailit-after/test/fixtures/.gitkeep
  58. +9 −0 episode-171/revised/mailit-after/test/fixtures/newsletters.yml
  59. 0 episode-171/revised/mailit-after/test/functional/.gitkeep
  60. 0 episode-171/revised/mailit-after/test/integration/.gitkeep
  61. +12 −0 episode-171/revised/mailit-after/test/performance/browsing_test.rb
  62. +13 −0 episode-171/revised/mailit-after/test/test_helper.rb
  63. 0 episode-171/revised/mailit-after/test/unit/.gitkeep
  64. 0 episode-171/revised/mailit-after/vendor/assets/stylesheets/.gitkeep
  65. 0 episode-171/revised/mailit-after/vendor/plugins/.gitkeep
  66. +15 −0 episode-171/revised/mailit-before/.gitignore
  67. +15 −0 episode-171/revised/mailit-before/Gemfile
  68. +118 −0 episode-171/revised/mailit-before/Gemfile.lock
  69. +9 −0 episode-171/revised/mailit-before/README
  70. +7 −0 episode-171/revised/mailit-before/Rakefile
  71. BIN episode-171/revised/mailit-before/app/assets/images/rails.png
  72. +9 −0 episode-171/revised/mailit-before/app/assets/javascripts/application.js
  73. +3 −0 episode-171/revised/mailit-before/app/assets/javascripts/newsletters.js.coffee
  74. +87 −0 episode-171/revised/mailit-before/app/assets/stylesheets/application.css
  75. +3 −0 episode-171/revised/mailit-before/app/assets/stylesheets/newsletters.css.scss
  76. +3 −0 episode-171/revised/mailit-before/app/controllers/application_controller.rb
  77. +48 −0 episode-171/revised/mailit-before/app/controllers/newsletters_controller.rb
  78. +2 −0 episode-171/revised/mailit-before/app/helpers/application_helper.rb
  79. +2 −0 episode-171/revised/mailit-before/app/helpers/newsletters_helper.rb
  80. 0 episode-171/revised/mailit-before/app/mailers/.gitkeep
  81. 0 episode-171/revised/mailit-before/app/models/.gitkeep
  82. +2 −0 episode-171/revised/mailit-before/app/models/newsletter.rb
  83. +18 −0 episode-171/revised/mailit-before/app/views/layouts/application.html.erb
  84. +19 −0 episode-171/revised/mailit-before/app/views/newsletters/_form.html.erb
  85. +6 −0 episode-171/revised/mailit-before/app/views/newsletters/edit.html.erb
  86. +14 −0 episode-171/revised/mailit-before/app/views/newsletters/index.html.erb
  87. +5 −0 episode-171/revised/mailit-before/app/views/newsletters/new.html.erb
  88. +15 −0 episode-171/revised/mailit-before/app/views/newsletters/show.html.erb
  89. +4 −0 episode-171/revised/mailit-before/config.ru
  90. +48 −0 episode-171/revised/mailit-before/config/application.rb
  91. +6 −0 episode-171/revised/mailit-before/config/boot.rb
  92. +25 −0 episode-171/revised/mailit-before/config/database.yml
  93. +5 −0 episode-171/revised/mailit-before/config/environment.rb
  94. +30 −0 episode-171/revised/mailit-before/config/environments/development.rb
  95. +60 −0 episode-171/revised/mailit-before/config/environments/production.rb
  96. +39 −0 episode-171/revised/mailit-before/config/environments/test.rb
  97. +7 −0 episode-171/revised/mailit-before/config/initializers/backtrace_silencers.rb
  98. +10 −0 episode-171/revised/mailit-before/config/initializers/inflections.rb
  99. +5 −0 episode-171/revised/mailit-before/config/initializers/mime_types.rb
  100. +7 −0 episode-171/revised/mailit-before/config/initializers/secret_token.rb
  101. +8 −0 episode-171/revised/mailit-before/config/initializers/session_store.rb
  102. +14 −0 episode-171/revised/mailit-before/config/initializers/wrap_parameters.rb
  103. +5 −0 episode-171/revised/mailit-before/config/locales/en.yml
  104. +6 −0 episode-171/revised/mailit-before/config/routes.rb
  105. +10 −0 episode-171/revised/mailit-before/db/migrate/20120107211315_create_newsletters.rb
  106. +23 −0 episode-171/revised/mailit-before/db/schema.rb
  107. +4 −0 episode-171/revised/mailit-before/db/seeds.rb
  108. +2 −0 episode-171/revised/mailit-before/doc/README_FOR_APP
  109. 0 episode-171/revised/mailit-before/lib/assets/.gitkeep
  110. 0 episode-171/revised/mailit-before/lib/tasks/.gitkeep
  111. 0 episode-171/revised/mailit-before/log/.gitkeep
  112. +26 −0 episode-171/revised/mailit-before/public/404.html
  113. +26 −0 episode-171/revised/mailit-before/public/422.html
  114. +26 −0 episode-171/revised/mailit-before/public/500.html
  115. 0 episode-171/revised/mailit-before/public/favicon.ico
  116. +5 −0 episode-171/revised/mailit-before/public/robots.txt
  117. +6 −0 episode-171/revised/mailit-before/script/rails
  118. 0 episode-171/revised/mailit-before/test/fixtures/.gitkeep
  119. +9 −0 episode-171/revised/mailit-before/test/fixtures/newsletters.yml
  120. 0 episode-171/revised/mailit-before/test/functional/.gitkeep
  121. 0 episode-171/revised/mailit-before/test/integration/.gitkeep
  122. +12 −0 episode-171/revised/mailit-before/test/performance/browsing_test.rb
  123. +13 −0 episode-171/revised/mailit-before/test/test_helper.rb
  124. 0 episode-171/revised/mailit-before/test/unit/.gitkeep
  125. 0 episode-171/revised/mailit-before/vendor/assets/stylesheets/.gitkeep
  126. 0 episode-171/revised/mailit-before/vendor/plugins/.gitkeep
View
@@ -0,0 +1,13 @@
+RailsCasts Episode #171: Delayed Job (revised)
+
+http://railscasts.com/episodes/171-delayed-job-revised
+
+Requires Ruby 1.9.2 or higher.
+
+Commands used in episode
+
+ rails g delayed_job:active_record
+ rake db:migrate
+ rake jobs:work
+ script/delayed_job start
+ script/delayed_job stop
@@ -0,0 +1,15 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+
+# Ignore all logfiles and tempfiles.
+/log/*.log
+/tmp
@@ -0,0 +1,19 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.3'
+
+gem 'sqlite3'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.5'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+gem 'daemons'
+gem 'delayed_job_active_record'
+gem "delayed_job_web"
@@ -0,0 +1,136 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ arel (2.2.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.2.0)
+ daemons (1.1.2)
+ delayed_job (3.0.0)
+ activesupport (~> 3.0)
+ delayed_job_active_record (0.3.1)
+ activerecord (> 2.1.0)
+ delayed_job (~> 3.0.0)
+ delayed_job_web (1.0.3)
+ activerecord (> 3.0.0)
+ delayed_job (> 2.0.3)
+ haml (~> 3.1.3)
+ rdoc
+ sinatra (>= 0.9.2)
+ erubis (2.7.0)
+ execjs (1.2.13)
+ multi_json (~> 1.0)
+ haml (3.1.4)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.4)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.3.6)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-protection (1.2.0)
+ rack
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sass (3.1.12)
+ sass-rails (3.1.5)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (~> 3.1.10)
+ tilt (~> 1.3.2)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ uglifier (1.2.1)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.1)
+ daemons
+ delayed_job_active_record
+ delayed_job_web
+ jquery-rails
+ rails (= 3.1.3)
+ sass-rails (~> 3.1.5)
+ sqlite3
+ uglifier (>= 1.0.3)
@@ -0,0 +1,9 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
+
+Requires Ruby 1.9.2 or higher.
@@ -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__)
+
+Mailit::Application.load_tasks
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,87 @@
+/*
+ * 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 .
+*/
+
+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;
+}
+
+.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;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+label.required {
+ font-weight: bold;
+}
+
+.newsletter h2 {
+ font-size: 18px;
+ margin-bottom: 2px;
+}
@@ -0,0 +1,3 @@
+// Place all the styles related to the newsletters controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,46 @@
+class NewslettersController < ApplicationController
+ def deliver
+ Newsletter.delay(queue: "newsletter", priority: 20, run_at: 5.minutes.from_now).deliver(params[:id])
+ redirect_to newsletters_url, notice: "Delivering newsletter."
+ end
+
+ def index
+ @newsletters = Newsletter.all
+ end
+
+ def show
+ @newsletter = Newsletter.find(params[:id])
+ end
+
+ def new
+ @newsletter = Newsletter.new
+ end
+
+ def create
+ @newsletter = Newsletter.new(params[:newsletter])
+ if @newsletter.save
+ redirect_to @newsletter, notice: "Successfully created newsletter."
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @newsletter = Newsletter.find(params[:id])
+ end
+
+ def update
+ @newsletter = Newsletter.find(params[:id])
+ if @newsletter.update_attributes(params[:newsletter])
+ redirect_to @newsletter, notice: "Successfully updated newsletter."
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @newsletter = Newsletter.find(params[:id])
+ @newsletter.destroy
+ redirect_to newsletters_url, notice: "Successfully destroyed newsletter."
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module NewslettersHelper
+end
@@ -0,0 +1,10 @@
+class Newsletter < ActiveRecord::Base
+ def self.deliver(id)
+ find(id).deliver
+ end
+
+ def deliver
+ sleep 10 # simulate long newsletter delivery
+ update_attribute(:delivered_at, Time.zone.now)
+ end
+end
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Newsletters</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tag %>
+ </head>
+ <body>
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, id: "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ <div class="clear"></div>
+ </div>
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 457b96b

Please sign in to comment.