Skip to content

Instantly share code, notes, and snippets.

@boie0025
boie0025 / Gemfile
Last active January 9, 2018 18:37 — forked from frznk-tank/Gemfile
Postgres Arrays in Active Admin
ruby '2.2.0'
source 'https://rubygems.org'
...
gem 'font-awesome-rails'
@boie0025
boie0025 / active_admin_model_stubs.rb
Last active September 11, 2017 21:57
ActiveAdmin Model Stubs - Form/Service objects
# Created by essentially answering all of the methods that were called on a PORO. Adjust as you see fit
module ActiveAdminModelStubs
extend ActiveSupport::Concern
# duck punch - ActiveAdmin uses these for index page. We don't have an index.
module ClassMethods
# Columns makes no sense in the context of a form.
def columns(*)
[]
@boie0025
boie0025 / gist:ae9697eed61cbf5342a6
Last active May 17, 2017 20:20
scraper-psuedocode-exmaple
module Producers
class DataModelA
... # Some ruby magic to return the correct subclass for a state
def page
@page ||= Nokogiri.new(URL)
end
end
class SpecificState < DataModelA
@boie0025
boie0025 / clean_versions.rake
Created December 7, 2012 18:26
Rake task for gem paper_trail to clean up unused versions.
namespace :utils do
desc "Clean up papertrail versions: delete unfound associations"
task :clean_versions => :environment do
Version.all.each do |ver|
klass = ver.item_type.constantize
#Call unscoped in case delete flag is set, and item is still in db.
item = klass.unscoped.find_by_id(ver.item_id)
if item.nil?