Rails 4.2 - Grape - IOError: not open for reading

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

In the interface, I have a JavaScript application created using EmberJS. Here's a link to the repo on GitHub .

I updated the following stones so that I can format my API responses according to the JSON API standard, which seems to need to be updated to Ember 1.13 and 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 get the following error when calling the API: IOError: does not open for reading

According to the information that I have collected here and there, I suspect that this is in conflict with the way I format JSON.

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

 formatter :json, Grape::Formatter::ActiveModelSerializers 

I no longer have any error, but obviously the answer is not serializable.

My questions:

  • Do you know how I can solve this?
  • Do you find it appropriate to use Grape to create an API in my Rails application? With the advent of Rails 5, is it not better for users to rails-api and rewrite the entire application? I mean, I'm starting, perhaps, the right time for this ...

Let me know if you need more information.

Thanks in advance for your help.

+7
json ruby-on-rails json-api grape-api
source share
1 answer

I ended up rewriting the entire API using jsonapi resources.

0
source share