Skip to content

Commit 6254a41

Browse files
committed
Implement column_for_attribute
1 parent f6e7cca commit 6254a41

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/active_admin/mongoid/document.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class << self
4747

4848
self.primary_key ||= :id
4949

50+
def column_for_attribute(name)
51+
self.class.fields[name.to_sym]
52+
end
53+
5054
end
5155

5256
module ClassMethods
@@ -92,12 +96,12 @@ module ClassMethods
9296

9397
# Columns
9498

95-
# def content_columns
96-
# # cannot cache this, since changes in time (while defining fields)
97-
# fields.map(&:second).reject do |f|
98-
# f.name =~ /(^_|^(created|updated)_at)/ or Mongoid::Fields::ForeignKey === f
99-
# end
100-
# end
99+
def content_columns
100+
# cannot cache this, since changes in time (while defining fields)
101+
fields.map(&:second).reject do |f|
102+
f.name =~ /(^_|^(created|updated)_at)/ or Mongoid::Fields::ForeignKey === f
103+
end
104+
end
101105

102106
# def columns
103107
# @columns ||= fields.map(&:second).map{ |c| ColumnWrapper.new(c) }

0 commit comments

Comments
 (0)