forked from ryanb/railscasts-episodes
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.bundle/ | ||
log/*.log | ||
pkg/ | ||
test/dummy/db/*.sqlite3 | ||
test/dummy/log/*.log | ||
test/dummy/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
episode-277/uhoh-after/app/assets/javascripts/uhoh/application.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . |
5 changes: 5 additions & 0 deletions
5
episode-277/uhoh-after/app/assets/javascripts/uhoh/failures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$(function() { | ||
$("li").click(function() { | ||
$(this).slideUp(); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
episode-277/uhoh-after/app/assets/stylesheets/uhoh/application.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . | ||
*/ |
29 changes: 29 additions & 0 deletions
29
episode-277/uhoh-after/app/assets/stylesheets/uhoh/failures.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
4 changes: 4 additions & 0 deletions
4
episode-277/uhoh-after/app/controllers/uhoh/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Uhoh | ||
class ApplicationController < ActionController::Base | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
episode-277/uhoh-after/app/controllers/uhoh/failures_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Uhoh | ||
class FailuresController < ApplicationController | ||
def index | ||
@failures = Failure.all | ||
end | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
episode-277/uhoh-after/app/helpers/uhoh/application_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Uhoh | ||
module ApplicationHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Uhoh | ||
module FailuresHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Uhoh | ||
class Failure < ActiveRecord::Base | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
episode-277/uhoh-after/app/views/layouts/uhoh/application.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
11 changes: 11 additions & 0 deletions
11
episode-277/uhoh-after/app/views/uhoh/failures/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
6 changes: 6 additions & 0 deletions
6
episode-277/uhoh-after/config/initializers/exception_handler.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Uhoh::Engine.routes.draw do | ||
root :to => "failures#index" | ||
end |
9 changes: 9 additions & 0 deletions
9
episode-277/uhoh-after/db/migrate/20110727184726_create_uhoh_failures.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateUhohFailures < ActiveRecord::Migration | ||
def change | ||
create_table :uhoh_failures do |t| | ||
t.text :message | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :uhoh do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require "uhoh/engine" | ||
|
||
module Uhoh | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Uhoh | ||
class Engine < Rails::Engine | ||
isolate_namespace Uhoh | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
9 changes: 9 additions & 0 deletions
9
episode-277/uhoh-after/test/dummy/app/assets/javascripts/application.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . |
2 changes: 2 additions & 0 deletions
2
episode-277/uhoh-after/test/dummy/app/assets/javascripts/simulate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
7 changes: 7 additions & 0 deletions
7
episode-277/uhoh-after/test/dummy/app/assets/stylesheets/application.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.