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

no implicit conversion of Symbol into Integer error using mongoid #589

Open
dclausen opened this issue Jan 15, 2016 · 2 comments
Open

no implicit conversion of Symbol into Integer error using mongoid #589

dclausen opened this issue Jan 15, 2016 · 2 comments

Comments

@dclausen
Copy link

Just upgraded to mongoid 5.0.2 and mongo 2.2.1 using latest release of jsonapi-resources 0.7 after which I began receiving a no implicit conversion of Symbol into Integer error.

This is due to lib/jsonapi/resource.rb:551 count(:all) is passing a Symbol to a delegated count method within mongo which expects a Hash.

It appears the bug to count() was caused by a change related to postgres support in d0e35b6

@mattxyzeth
Copy link

I have the same issue except my error was different. Mine was complaining about the wrong number of arguments (1 for 0).

I have a temporary fix for now. Create a base resource class that your resources inherit from and add these lines:

class << self
  def find_count(filters, options = {})
    filter_records(filters, options).count
  end
end

@blmundie
Copy link

I had to override find_count and put the following in an initializer

class JSONAPI::ShowRelatedResourcesOperation
  def record_count
    @_record_count ||= records.count()
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants