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

Conform to ActiveModel::Serializers' way of determining array-ness #6

Merged
merged 1 commit into from
Jul 19, 2013

Conversation

tfe
Copy link
Contributor

@tfe tfe commented Jun 20, 2013

I ran into a problem with a model that uses friendly_id where the collection returned was a FriendlyIdActiveRecordRelation, which of course did not give the right answer when we asked it is_a?(Array).

So I looked at how ActiveModel::Serializers does its determination of whether a resource is an array, and it calls respond_to?(:to_ary) (c.f. https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/serializer.rb#L274). So I just did the same.

…rs itself uses. This should be more reliable and it's probably good to conform to AM::Serializers behavior wherever possible.
jrhe added a commit that referenced this pull request Jul 19, 2013
Conform to ActiveModel::Serializers' way of determining array-ness
@jrhe jrhe merged commit 6700eb2 into ruby-grape:master Jul 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants