Rails 4.2 - Grape - IOError: Not opened for reading
Asked Answered
D

1

7

I'm building an API with Grape on Rails 4.2. Here's a link to the repo on GitHub.

On the frontend, I have a JavaScript application built with EmberJS. Here's the link to the repo on GitHub as well.

I have updated the following gems so that I can format the responses of my API following JSON API standard, which appears to be required to update to Ember 1.13, then to Ember 2.0.

gem "active_model_serializers", '0.10.0.rc2'
gem "grape"
gem "grape-active_model_serializers", :git => 'https://github.com/jrhe/grape-active_model_serializers.git'

After that, I've got the following error when I call the API: IOError: Not opened for reading

According to the information I gathered here and there, I suspect this is a conflict with how I format JSON.

In default.rb, the file that inherit all API controllers, when I comment this line:

formatter :json, Grape::Formatter::ActiveModelSerializers

I don't have any error anymore, but obviously the response isn't serialized.

My questions are:

  • Do you have any idea how I can solve this?
  • Do you think it's relevant to use Grape to build the API in my Rails app? With Rails 5 coming, isn't that better to user rails-api and rewrite the whole app? I mean, I'm starting, it's maybe the right time to do that...

Let me know if you need more information.

Thanks in advance for your help.

Deformed answered 7/7, 2015 at 20:35 Comment(0)
D
0

I ended up rewriting the whole API using jsonapi-resources.

Deformed answered 3/8, 2015 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.