Skip to content

Instantly share code, notes, and snippets.

@mimosz
mimosz / active_admin_dsl.rb
Created August 31, 2011 10:14
add awesome_nested_set helper nested_set_options Support On Active Admin
# /lib/active_admin_dsl.rb
require 'active_admin/dsl.rb'
include CollectiveIdea::Acts::NestedSet::Helper
@mimosz
mimosz / active_admin_views_pages_base.rb
Created August 31, 2011 09:50 — forked from jocubeit/active_admin_views_pages_base.rb
Override footer content in Active Admin gem
# encoding: utf-8
ActiveAdmin::Views::Pages::Base.class_eval do
private
# Renders the content for the footer
def build_footer
div :id => "footer" do
para "Copyright © #{Date.today.year.to_s} #{link_to('Example.com', 'http://example.com')}. Powered by #{link_to('Active Admin', 'http://www.activeadmin.info')} #{ActiveAdmin::VERSION}".html_safe
end
end
end
@mimosz
mimosz / activity.rb
Created June 12, 2011 04:47
Mongoid::Activity::Trackable
## 引入文件
# require 'mongoid/activity'
## 插入Document行後
# include Mongoid::Activity::Trackable
# 啟用跟蹤
# tracking :person => :follower, :scope => :followable, :create_bones => 5, :destroy_bones => -3
module Mongoid
module Activity
module Trackable
extend ActiveSupport::Concern
@mimosz
mimosz / counter_cache.rb
Created June 7, 2011 08:18
Mongoid counter cache
## 引入文件
# require 'mongoid/counter_cache'
## 插入Document行後
# include Mongoid::Relations::CounterCache
## 默認
# referenced_in :person, :inverse_of => :posts, :counter_cache => true
## 自定義
# referenced_in :person, :inverse_of => :posts, :counter_cache => :posts_count
module Mongoid