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
# Caches Arbre elements in the `Rails.cache`. | |
# | |
# Yielding the first time adds to the output buffer regardless of the | |
# returned value. A cache miss must be handled separately from a hit | |
# to avoid double rendering. | |
# | |
# Returns yielded Arbre on cache miss OR an HTML string wrapped in | |
# an text node on cache hit. | |
def cache_arbre(context, *args, &block) | |
if controller.perform_caching |
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
task :active_admin_actions => :environment do | |
skip_resources = [ 'Dashboard' ] | |
namespace = ActiveAdmin.application.namespace(:admin) | |
pages = namespace.resources.select { |r| r.is_a? ActiveAdmin::Page } | |
resources = namespace.resources.select { |r| r.respond_to? :resource_class } | |
resource_actions = | |
resources.each_with_object({}) do |resource, actions| |
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
# Public: Template to render views outside the context of a controller. | |
# | |
# Useful for rendering Rails 2.3.x views in rake tasks or background jobs when a | |
# controller is unavailable. | |
# | |
# Examples | |
# | |
# template = OfflineTemplate.new(:users) | |
# template.render("users/index", :layout => false, :locals => { :users => users }) | |
# |
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
module PostgresCopyCsv | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Performs a database query to copy results as CSV to an IO object. | |
# | |
# CSV is created directly in PostgreSQL with less overhead then written to | |
# the provided IO object. | |
# | |
# Example |
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
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", github: "rails/rails" |
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
require 'spec_helper' | |
describe ActiveAdmin::ResourceCollection do | |
let(:application) { ActiveAdmin::Application.new } | |
let(:namespace) { ActiveAdmin::Namespace.new(application, :admin) } | |
context ".add" do | |
let(:resource) { ActiveAdmin::Resource.new(namespace, AdminUser) } | |
let(:resource_renamed) { ActiveAdmin::Resource.new(namespace, AdminUser, as: "SuperAdminUser") } |
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
namespace :deploy do | |
namespace :assets do | |
task :precompile, :roles => :web, :except => { :no_release => true } do | |
assets_path = File.join(release_path, "public/assets") | |
assets_empty = capture("ls -x #{assets_path}").length == 0 | |
has_current_release = capture("if [ -d #{current_path} ]; then echo -n \"yes\"; fi") == "yes" | |
compile_assets = false |
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
def run_all_tests | |
# see Rakefile for the definition of the test:all task | |
system( "rake -s test" ) | |
end | |
def run(cmd) | |
puts(cmd) | |
system(cmd) | |
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
!/bin/bash | |
cd /tmp | |
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz | |
tar xzf rubygems-1.3.7.tgz | |
cd rubygems-1.3.7 | |
sudo ruby ./setup.rb |
NewerOlder