Skip to content

Instantly share code, notes, and snippets.

@Fivell
Fivell / gist:8151821
Created December 27, 2013 19:54
ActiveAdmin Dynamic filters fix
module ActiveAdmin
module Filters
# This form builder defines methods to build filter forms such
# as the one found in the sidebar of the index page of a standard resource.
class FormBuilder < ::ActiveAdmin::FormBuilder
include ::ActiveAdmin::Filters::FormtasticAddons
def initialize(*args)
@use_form_buffer = true # force ActiveAdmin::FormBuilder to use the form buffer
@Fivell
Fivell / gist:8075775
Created December 21, 2013 22:12
aa page block
&ActiveAdmin.application.namespace(:root).resources["Not Found"].get_page_presenter('index').block
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@Fivell
Fivell / have_xml.rb
Created December 18, 2013 17:00 — forked from faun/have_xml.rb
require 'nokogiri'
RSpec::Matchers.define :have_xml do |xpath, text|
match do |body|
doc = Nokogiri::XML::Document.parse(body)
nodes = doc.xpath(xpath)
nodes.empty?.should be_false
if text
nodes.each do |node|
node.content.should == text
end
@Fivell
Fivell / EmailExceptionNotification
Created December 16, 2013 23:17
EmailExceptionNotification module
module EmailExceptionNotification
def self.included(base)
base.rescue_from StandardError, :with => :handle_exceptions
end
def handle_exceptions(e)
deliver_exception(e)
raise e
end
@Fivell
Fivell / gist:7570698
Created November 20, 2013 20:46 — forked from dwg/gist:7372744
# Base class
class DynamicHostMailer < ActionMailer::Base
def initialize method_name=nil, host, *args
@host = host
super method_name, *args
end
def url_options
# Host should be checked against a relevant whitelist, this is only an example
{ host: @host }
@Fivell
Fivell / dbclock.rb
Created October 20, 2013 18:55 — forked from ianneub/dbclock.rb
# version 1
require 'clockwork'
require './config/boot'
require './config/environment'
module DBBackedClockwork
extend Clockwork
# add a periodic job to update @@events
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
require 'torquebox-stomp'
class DemoStomplet
def initialize()
super
@subscribers = []
# passthrough for local messages to skip auth
@passthrough_code = "e32f53ac7569ae3a1f692177"
end