undefined method `id' for true:TrueClass #25

Closed
aminhotob opened this Issue Oct 6, 2012 · 11 comments

Comments

Projects
None yet
5 participants

Showing /usr/local/lib/ruby/gems/1.9.1/gems/activeadmin-0.5.0/app/views/active_admin/resource/index.html.arb where line #1 raised:

undefined method `id' for true:TrueClass
Extracted source (around line #1):

1: insert_tag renderer_for(:index)

Trace in this Gist

The last commit/pull merge appears to have caused this issue.
I got a fresh install to work by using previous commit and activeadmin 0.4.4

gem 'activeadmin-mongoid',  git: 'git://github.com/elia/activeadmin-mongoid.git', ref: 'd3d05ee9f005a01b7e19b4a5c98ee912f4e5a263'
gem 'activeadmin', '~> 0.4.0'

(it looks like true is being passed into mongoid3 lib/mongoid/contextual/mongo.rb#count where a document is expected)
e7b8744

Ok, Thanks @jonaustin it works

ivoreis commented Oct 11, 2012

The problem is inside the mongoid/helpers/collection.rb
Just remove collection.count(true) to be like this

      def collection_size(collection=collection)
        collection.count
      end

The reason is that mongodb count supports a parameter but for filtering.

You can also point the gem activeadmin to the master 0.5.0 with this fix

@ghost

ghost commented Oct 15, 2012

@ivoreis I've got

gem 'activeadmin-mongoid', git: "git://github.com/elia/activeadmin-mongoid.git"

in my Gemfile, but the change you mentioned is not in there. A bundle open activeadmin-mongoid shows:

module ActiveAdmin
  module Helpers
    module Collection
      def collection_size(collection=collection)
        collection.count(true)
      end
    end
  end
end

ivoreis commented Oct 15, 2012

@bluemont Just remove the true from count method. The end result should be collection.count

ivoreis commented Oct 15, 2012

if you want just point the gem to OsTrzy's fork and that should be fixed! Also the filter support is added.

gem 'activeadmin-mongoid', :git => 'git://github.com/Ostrzy/activeadmin-mongoid.git', :branch => 'filter_support'
@ghost

ghost commented Oct 15, 2012

Thanks. For the time being, I'm monkey patching via a Rails initializer.

@matekb matekb added a commit to matekb/activeadmin-mongoid that referenced this issue Nov 8, 2012

@matekb matekb fixes #25 according to ivoreis comment. 1fa5ea3

matekb referenced this issue Nov 8, 2012

Merged

Fix for issue #25 #27

elia closed this in 1fa5ea3 Nov 8, 2012

elia reopened this Nov 8, 2012

Member

elia commented Nov 9, 2012

Sorry for the lack of participation I merged the pr from @matekb, @iameen can you confirm it works?

I'm trying to get the original activeadmin test suite to work on activeadmin-mongoid.
The branch is active-admin-spec-suite, any help or feedback is welcome :)

@elia I test your merge using gem "activeadmin-mongoid", git: "git://github.com/elia/activeadmin-mongoid.git" and it works for me
Thanks

@ghost

ghost commented Nov 13, 2012

It works for me, too (using the Gemfile syntax that iAmeen mentions). Now I don't have to monkey patch. Thanks.

Member

elia commented Nov 13, 2012

Good, hope to release an update soon :)

elia closed this Nov 13, 2012

@fred fred pushed a commit to fred/activeadmin-mongoid that referenced this issue Jul 30, 2013

@matekb matekb fixes #25 according to ivoreis comment. 09bed17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment