Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1, uncomment methods that are still used in activeadmin #96

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/active_admin/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
require 'active_admin/mongoid/criteria'

require 'active_admin/mongoid/order_clause'
require 'active_admin/mongoid/filters/formtastic_addons'

module ActiveAdmin
module Mongoid
Expand Down
16 changes: 10 additions & 6 deletions lib/active_admin/mongoid/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class << self

self.primary_key ||= :id

def column_for_attribute(name)
self.class.fields[name.to_sym]
end

end

module ClassMethods
Expand Down Expand Up @@ -92,12 +96,12 @@ module ClassMethods

# Columns

# def content_columns
# # cannot cache this, since changes in time (while defining fields)
# fields.map(&:second).reject do |f|
# f.name =~ /(^_|^(created|updated)_at)/ or Mongoid::Fields::ForeignKey === f
# end
# end
def content_columns
# cannot cache this, since changes in time (while defining fields)
fields.map(&:second).reject do |f|
f.name =~ /(^_|^(created|updated)_at)/ or Mongoid::Fields::ForeignKey === f
end
end

# def columns
# @columns ||= fields.map(&:second).map{ |c| ColumnWrapper.new(c) }
Expand Down
12 changes: 0 additions & 12 deletions lib/active_admin/mongoid/filters/formtastic_addons.rb

This file was deleted.

15 changes: 6 additions & 9 deletions lib/active_admin/mongoid/helpers/collection.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
module ActiveAdmin
module Helpers
module Collection

alias original_collection_size collection_size
original_collection_size = instance_method(:collection_size)
def collection_size(collection=collection)
if(not collection.empty? and collection.first.class.included_modules.include?(Mongoid::Document))
if collection.first.class.embedded?
collection.count
def collection_size(c=collection)
if(not c.empty? and c.first.class.included_modules.include?(Mongoid::Document))
if c.first.class.embedded?
c.count
else
collection.count(true)
c.count(true)
end
else
collection.count
c.count
end
end
end
Expand Down