Permalink
Browse files

adding episode 277

  • Loading branch information...
1 parent b5db06c commit 7952d134c5832462d3962f6ad13799c413ab7a43 @ryanb committed Jul 29, 2011
Showing with 848 additions and 0 deletions.
  1. +14 −0 episode-277/README
  2. +6 −0 episode-277/uhoh-after/.gitignore
  3. +12 −0 episode-277/uhoh-after/Gemfile
  4. +93 −0 episode-277/uhoh-after/Gemfile.lock
  5. +20 −0 episode-277/uhoh-after/MIT-LICENSE
  6. +20 −0 episode-277/uhoh-after/README.rdoc
  7. +39 −0 episode-277/uhoh-after/Rakefile
  8. 0 episode-277/uhoh-after/app/assets/images/uhoh/.gitkeep
  9. BIN episode-277/uhoh-after/app/assets/images/uhoh/alert.png
  10. +9 −0 episode-277/uhoh-after/app/assets/javascripts/uhoh/application.js
  11. +5 −0 episode-277/uhoh-after/app/assets/javascripts/uhoh/failures.js
  12. +7 −0 episode-277/uhoh-after/app/assets/stylesheets/uhoh/application.css
  13. +29 −0 episode-277/uhoh-after/app/assets/stylesheets/uhoh/failures.css
  14. +4 −0 episode-277/uhoh-after/app/controllers/uhoh/application_controller.rb
  15. +7 −0 episode-277/uhoh-after/app/controllers/uhoh/failures_controller.rb
  16. +4 −0 episode-277/uhoh-after/app/helpers/uhoh/application_helper.rb
  17. +4 −0 episode-277/uhoh-after/app/helpers/uhoh/failures_helper.rb
  18. +4 −0 episode-277/uhoh-after/app/models/uhoh/failure.rb
  19. +14 −0 episode-277/uhoh-after/app/views/layouts/uhoh/application.html.erb
  20. +11 −0 episode-277/uhoh-after/app/views/uhoh/failures/index.html.erb
  21. +6 −0 episode-277/uhoh-after/config/initializers/exception_handler.rb
  22. +3 −0 episode-277/uhoh-after/config/routes.rb
  23. +9 −0 episode-277/uhoh-after/db/migrate/20110727184726_create_uhoh_failures.rb
  24. +4 −0 episode-277/uhoh-after/lib/tasks/uhoh_tasks.rake
  25. +4 −0 episode-277/uhoh-after/lib/uhoh.rb
  26. +5 −0 episode-277/uhoh-after/lib/uhoh/engine.rb
  27. +6 −0 episode-277/uhoh-after/script/rails
  28. +7 −0 episode-277/uhoh-after/test/dummy/Rakefile
  29. +9 −0 episode-277/uhoh-after/test/dummy/app/assets/javascripts/application.js
  30. +2 −0 episode-277/uhoh-after/test/dummy/app/assets/javascripts/simulate.js
  31. +7 −0 episode-277/uhoh-after/test/dummy/app/assets/stylesheets/application.css
  32. +4 −0 episode-277/uhoh-after/test/dummy/app/assets/stylesheets/simulate.css
  33. +3 −0 episode-277/uhoh-after/test/dummy/app/controllers/application_controller.rb
  34. +6 −0 episode-277/uhoh-after/test/dummy/app/controllers/simulate_controller.rb
  35. +2 −0 episode-277/uhoh-after/test/dummy/app/helpers/application_helper.rb
  36. +2 −0 episode-277/uhoh-after/test/dummy/app/helpers/simulate_helper.rb
  37. 0 episode-277/uhoh-after/test/dummy/app/mailers/.gitkeep
  38. 0 episode-277/uhoh-after/test/dummy/app/models/.gitkeep
  39. +14 −0 episode-277/uhoh-after/test/dummy/app/views/layouts/application.html.erb
  40. +2 −0 episode-277/uhoh-after/test/dummy/app/views/simulate/failure.html.erb
  41. +4 −0 episode-277/uhoh-after/test/dummy/config.ru
  42. +42 −0 episode-277/uhoh-after/test/dummy/config/application.rb
  43. +10 −0 episode-277/uhoh-after/test/dummy/config/boot.rb
  44. +25 −0 episode-277/uhoh-after/test/dummy/config/database.yml
  45. +5 −0 episode-277/uhoh-after/test/dummy/config/environment.rb
  46. +27 −0 episode-277/uhoh-after/test/dummy/config/environments/development.rb
  47. +51 −0 episode-277/uhoh-after/test/dummy/config/environments/production.rb
  48. +39 −0 episode-277/uhoh-after/test/dummy/config/environments/test.rb
  49. +7 −0 episode-277/uhoh-after/test/dummy/config/initializers/backtrace_silencers.rb
  50. +10 −0 episode-277/uhoh-after/test/dummy/config/initializers/inflections.rb
  51. +5 −0 episode-277/uhoh-after/test/dummy/config/initializers/mime_types.rb
  52. +7 −0 episode-277/uhoh-after/test/dummy/config/initializers/secret_token.rb
  53. +8 −0 episode-277/uhoh-after/test/dummy/config/initializers/session_store.rb
  54. +12 −0 episode-277/uhoh-after/test/dummy/config/initializers/wrap_parameters.rb
  55. +5 −0 episode-277/uhoh-after/test/dummy/config/locales/en.yml
  56. +6 −0 episode-277/uhoh-after/test/dummy/config/routes.rb
  57. +21 −0 episode-277/uhoh-after/test/dummy/db/schema.rb
  58. 0 episode-277/uhoh-after/test/dummy/lib/assets/.gitkeep
  59. 0 episode-277/uhoh-after/test/dummy/log/.gitkeep
  60. +26 −0 episode-277/uhoh-after/test/dummy/public/404.html
  61. +26 −0 episode-277/uhoh-after/test/dummy/public/422.html
  62. +26 −0 episode-277/uhoh-after/test/dummy/public/500.html
  63. 0 episode-277/uhoh-after/test/dummy/public/favicon.ico
  64. +6 −0 episode-277/uhoh-after/test/dummy/script/rails
  65. +9 −0 episode-277/uhoh-after/test/dummy/test/functional/simulate_controller_test.rb
  66. +4 −0 episode-277/uhoh-after/test/dummy/test/unit/helpers/simulate_helper_test.rb
  67. +7 −0 episode-277/uhoh-after/test/fixtures/uhoh/failures.yml
  68. +11 −0 episode-277/uhoh-after/test/functional/uhoh/failures_controller_test.rb
  69. +10 −0 episode-277/uhoh-after/test/integration/navigation_test.rb
  70. +10 −0 episode-277/uhoh-after/test/test_helper.rb
  71. +7 −0 episode-277/uhoh-after/test/uhoh_test.rb
  72. +6 −0 episode-277/uhoh-after/test/unit/helpers/uhoh/failures_helper_test.rb
  73. +9 −0 episode-277/uhoh-after/test/unit/uhoh/failure_test.rb
  74. +10 −0 episode-277/uhoh-after/uhoh.gemspec
View
@@ -0,0 +1,14 @@
+RailsCasts Episode #277 Mountable Engines
+
+http://railscasts.com/episodes/277-mountable-engines
+
+Commands used in episode
+
+ rails -v
+ rails plugin new uhoh --mountable
+ rails g controller failures index
+ rails g model failure message:text
+ rake db:migrate
+ rake uhoh:install:migrations
+ cd test/dummy
+ rails g controller simulate failure
@@ -0,0 +1,6 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
@@ -0,0 +1,12 @@
+source "http://rubygems.org"
+
+gem 'rails', '3.1.0.rc5'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+gem 'jquery-rails'
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
@@ -0,0 +1,93 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0.rc5)
+ actionpack (= 3.1.0.rc5)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.rc5)
+ activemodel (= 3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.1)
+ rack-cache (~> 1.0.2)
+ rack-mount (~> 0.8.1)
+ rack-test (~> 0.6.0)
+ sprockets (~> 2.0.0.beta.12)
+ activemodel (3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0.rc5)
+ activemodel (= 3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ arel (~> 2.1.4)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0.rc5)
+ activemodel (= 3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ activesupport (3.1.0.rc5)
+ multi_json (~> 1.0)
+ arel (2.1.4)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ erubis (2.7.0)
+ hike (1.2.0)
+ i18n (0.6.0)
+ jquery-rails (1.0.12)
+ 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.2)
+ 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.1)
+ rack (>= 1.0)
+ rails (3.1.0.rc5)
+ actionmailer (= 3.1.0.rc5)
+ actionpack (= 3.1.0.rc5)
+ activerecord (= 3.1.0.rc5)
+ activeresource (= 3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ bundler (~> 1.0)
+ railties (= 3.1.0.rc5)
+ railties (3.1.0.rc5)
+ actionpack (= 3.1.0.rc5)
+ activesupport (= 3.1.0.rc5)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.8)
+ sprockets (2.0.0.beta.12)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.2)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.29)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ jquery-rails
+ rails (= 3.1.0.rc5)
+ sqlite3
@@ -0,0 +1,20 @@
+Copyright 2011 YOURNAME
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
+= Uhoh
+
+This is a mountable engine created in RailsCasts episode #277. This is not a gem so these instructions will not work, but you can use this as an example readme for your own mountable engine.
+
+== Installation
+
+First add the gem to your Gemfile and run the bundle command.
+
+ gem 'uhoh'
+
+Next, mount the engine in your routes.rb under the path you want.
+
+ mount Uhoh::Engine => "/uhoh"
+
+Then copy over the migrations and run them.
+
+ rake uhoh:install:migrations
+ rake db:migrate
+
+Now when an exception is raised in your application it should be browsable at the "/uhoh" path. Don't forget to password protect if you're using this in production.
@@ -0,0 +1,39 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
+end
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Uhoh'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
+load 'rails/tasks/engine.rake'
+
+
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
+end
+
+
+task :default => :test
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,5 @@
+$(function() {
+ $("li").click(function() {
+ $(this).slideUp();
+ });
+});
@@ -0,0 +1,7 @@
+/*
+ * 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 .
+*/
@@ -0,0 +1,29 @@
+html, body {
+ background-color: #DDD;
+ font-family: Verdana;
+}
+
+body {
+ padding: 20px 200px;
+}
+
+img {
+ display: block;
+ margin: 0 auto;
+}
+
+a {
+ color: #000;
+}
+
+ul {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+li {
+ background-color: #FFF;
+ margin-bottom: 10px;
+ padding: 5px 10px;
+}
@@ -0,0 +1,4 @@
+module Uhoh
+ class ApplicationController < ActionController::Base
+ end
+end
@@ -0,0 +1,7 @@
+module Uhoh
+ class FailuresController < ApplicationController
+ def index
+ @failures = Failure.all
+ end
+ end
+end
@@ -0,0 +1,4 @@
+module Uhoh
+ module ApplicationHelper
+ end
+end
@@ -0,0 +1,4 @@
+module Uhoh
+ module FailuresHelper
+ end
+end
@@ -0,0 +1,4 @@
+module Uhoh
+ class Failure < ActiveRecord::Base
+ end
+end
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Uhoh</title>
+ <%= stylesheet_link_tag "uhoh/application" %>
+ <%= javascript_include_tag "uhoh/application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
@@ -0,0 +1,11 @@
+<%= image_tag "uhoh/alert.png" %>
+
+<h1>Failures</h1>
+<ul>
+ <% for failure in @failures %>
+ <li><%= failure.message %></li>
+ <% end %>
+</ul>
+
+<p><%= link_to "Failures", root_url %></p>
+<p><%= link_to "Simulate Failure", main_app.simulate_failure_path %></p>
@@ -0,0 +1,6 @@
+ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
+ if payload[:exception]
+ name, message = *payload[:exception]
+ Uhoh::Failure.create!(:message => message)
+ end
+end
@@ -0,0 +1,3 @@
+Uhoh::Engine.routes.draw do
+ root :to => "failures#index"
+end
@@ -0,0 +1,9 @@
+class CreateUhohFailures < ActiveRecord::Migration
+ def change
+ create_table :uhoh_failures do |t|
+ t.text :message
+
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :uhoh do
+# # Task goes here
+# end
@@ -0,0 +1,4 @@
+require "uhoh/engine"
+
+module Uhoh
+end
@@ -0,0 +1,5 @@
+module Uhoh
+ class Engine < Rails::Engine
+ isolate_namespace Uhoh
+ end
+end
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+#!/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.
+
+ENGINE_PATH = File.expand_path('../..', __FILE__)
+load File.expand_path('../../test/dummy/script/rails', __FILE__)
@@ -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__)
+
+Dummy::Application.load_tasks
@@ -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,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
@@ -0,0 +1,7 @@
+/*
+ * 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 .
+*/
Oops, something went wrong.

0 comments on commit 7952d13

Please sign in to comment.