Skip to content

Commit

Permalink
Add Mongoid::Document.primary_key (with spec)
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 30, 2012
1 parent d449bc8 commit e9b7edf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/active_admin/mongoid/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module ActiveAdmin::Mongoid::Document
extend ActiveSupport::Concern

module ClassMethods
def content_columns
@content_columns ||= fields.map(&:second).select {|f| f.name !~ /(^_|^(created|updated)_at)/}
Expand All @@ -11,10 +11,14 @@ def content_columns
def columns
@columns ||= fields.map(&:second)
end

def reorder *args
scoped
end

def primary_key
:_id
end
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/active_admin/mongoid/document_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'
require 'active_admin/mongoid/document'

describe ActiveAdmin::Mongoid::Document do
# let(:resource_class) { Class.new.tap { include Mongoid::Document } }
describe '.primary_key' do
it 'responds' do
Post.primary_key.should eq(:_id)
# resource_class.human_attribute_name(resource_class.primary_key)
end
end
end

0 comments on commit e9b7edf

Please sign in to comment.