Skip to content

Instantly share code, notes, and snippets.

View adamrobbie's full-sized avatar

Adam Robbie adamrobbie

View GitHub Profile
module SoftDeletable
extend ActiveSupport::Concern
def soft_delete!
find_each do |record|
record.soft_delete!
end
end
included do
# == Paperclip without ActiveRecord
#
# Simple and lightweight object that can use Paperclip
#
#
# Customized part can be extracted in another class which
# would inherit from SimplePaperclip.
#
# class MyClass < SimplePaperclip
# attr_accessor :image_file_name # :<atached_file_name>_file_name
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require File.dirname(__FILE__) + '/blueprints'
require 'faker'
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
class MiniTest::Unit::TestCase
include MiniTest::ActiveRecordAssertions
module MiniTest
module Assertions
module ActiveRecord
# assert_association User, :has_many, :editables, :polymorphic => true
#
def assert_association(clazz, association, associate, options={})
reflected_assoc = clazz.reflect_on_association(associate)
@adamrobbie
adamrobbie / controller.rb
Created August 30, 2012 13:42 — forked from joakimk/controller.rb
A way to lazy load partials in Rails 3
class Controller
include LazyLoad
def show
@model = Model.find(...)
respond_to do |format|
format.html do
@html_specific_data = Model.find(...)
end
@adamrobbie
adamrobbie / async_helper.rb
Created August 3, 2012 14:48
Rails Helper to call javascript asynchronous
module AsyncHelper
def javascript_async(*args)
content_tag :script, type: "text/javascript" do
"(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = '#{j javascript_path(*args)}';
var other = document.getElementsByTagName('script')[0];
@adamrobbie
adamrobbie / gist:3194878
Created July 28, 2012 21:31 — forked from iamjpg/gist:3194394
The Iron by Henry Rollins
This article originally appeared in Details Magazine some time around 1994 or 1995, I believe. This is a great essay by Henry Rollins on the benefits and lessons of lifting weights.
=================================================
I believe that the definition of definition is reinvention. To not be like your parents. To not be like your friends. To be yourself.
Completely.
When I was young I had no sense of myself. All I was, was a product of all the fear and humiliation I suffered. Fear of my parents. The humiliation of teachers calling me "garbage can" and telling me I'd be mowing lawns for a living. And the very real terror of my fellow students. I was threatened and beaten up for the color of my skin and my size. I was skinny and clumsy, and when others would tease me I didn't run home crying, wondering why.
@adamrobbie
adamrobbie / Example html
Created June 19, 2012 22:09 — forked from barryvdh/Example html
Sticky Footer (Less)
<div class="wrapper">
<div class="container">
<header>
</header>
<div id="content">
</div>
</div>
<div class="footer-push"></div>