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

How to serialize an array? #891

Closed
AlexCppns opened this issue Apr 28, 2015 · 5 comments
Closed

How to serialize an array? #891

AlexCppns opened this issue Apr 28, 2015 · 5 comments

Comments

@AlexCppns
Copy link

I am getting the following error:

NoMethodError - undefined method `read_attribute_for_serialization' for #Array:0x007fd3e1151898

Ruby code in controller:

@results = Record.search(size: 8, query: { match: { name: { query: params[:name], operator: 'and' } } })
@records = @results.records.records << Record.last(5)
 respond_with(@records, each_serializer: RecordSerializer)
@prasadsurase
Copy link

Use ArraySerializer as

ActiveModel::ArraySerializer.new(@records, each_serializer: RecordSerializer).to_json

@ericdfields
Copy link

@prasadsurase that used to be the case in 0.9.3. I'm trying to upgrade to 0.10.0.rc1 and finding that ActiveModel::ArraySerializer doesn't exist anymore…

@mcmire
Copy link

mcmire commented May 7, 2015

Looks like it moved to ActiveModel::Serializer::ArraySerializer.

@AlexCppns
Copy link
Author

I fixed the problem, thanks :).

@joaomdmoura
Copy link
Member

Tks everyone 😄 you're awesome
It's hard to follow up ever thread 😝

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

No branches or pull requests

5 participants