· 1 min read

Screencast: Mountbare Engines

Downloads in verschiedenen Formaten:

source code

mp4

m4v

webm

ogv

Resourcen:

bash

[bash] 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 [/bash]

uhoh/failures_controller.rb

[ruby] module Uhoh class FailuresController < ApplicationController def index @failures = Failure.all end end end [/ruby]

uhoh/failures/index.html.erb

[html]

Failures

[/html]

config/routes.rb

[ruby] root :to => “failures#index” [/ruby]

config/initializers/exception_handler.rb

[ruby] 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 [/ruby]

test/dummy/config/routes.rb

[ruby] mount Uhoh::Engine => “/uhoh”, :as => “uhoh_engine” [/ruby]

test/dummy/app/controllers/simulate_controller.rb

[ruby] def failure # redirect_to uhoh_engine.root_url raise “Simulating an exception” end [/ruby]

Back to Blog