Skip to content

Carrierwave Entity#serializable_hash doesn't take a parameter #311

Closed
@lhm

Description

@lhm

I just upgraded grape from 0.2.1 to 0.2.5, and now I'm getting errors from the carrierwave gem:

ArgumentError (wrong number of arguments (1 for 0)):
  carrierwave (0.8.0) lib/carrierwave/uploader/serialization.rb:11:in `serializable_hash'
  grape (0.2.5) lib/grape/entity.rb:320:in `block in serializable_hash'
  grape (0.2.5) lib/grape/entity.rb:315:in `each'
  grape (0.2.5) lib/grape/entity.rb:315:in `inject'
  grape (0.2.5) lib/grape/entity.rb:315:in `serializable_hash'

I believe that the problem is that carrierwave also implements #serializable_hash which gets included in the models that use it for image uploading. This causes this line in entity.rb to return true:

https://github.com/intridea/grape/blob/master/lib/grape/entity.rb#L319

and then calls carrierwave's #serializable_hash with an argument - which it doesn't accept:

https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/uploader/serialization.rb#L11

I'm not entirely sure who's at fault here. If grape expects to call it's own serializable_hash method (i.e. only Entities, or Models that mixin the DSL) than it would probably be better to check for the class instead of duck-typing.

On the other hand, if it's just following rails' serializable_hash protocol, then carrierwave should probably implement the correct method signature, I think.

FWIW, the pull request that brought this line in is #181

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions