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

Rails 5 api-only ignoring rabl files #687

Closed
willc0de4food opened this issue Jan 25, 2017 · 3 comments · Fixed by #711
Closed

Rails 5 api-only ignoring rabl files #687

willc0de4food opened this issue Jan 25, 2017 · 3 comments · Fixed by #711

Comments

@willc0de4food
Copy link

I wrote an API app in Rails 4.2 and used rabl to render output. I've recently update the app to use Rails 5 (generated a new app and copied the code over), and since then - all of my API calls get an empty response. I've put a debugger in the controller code to ensure that there is data to render. Does rabl work with Rails 5?

@emaillenin
Copy link

+1

Rails - 5.0.2
Rabl - 0.13.1

Getting an empty response. Works fine when we manually render the JSON using .to_json method like:

render json: @post.to_json

@emaillenin
Copy link

emaillenin commented May 27, 2017

Someone commented this here and then deleted it. Adding it here as reference since it solved this issue.

Adding gem 'jbuilder', '~> 2.5' to the Gemfile solves this. No idea how jbuilder and rabl are related.

Repository owner deleted a comment from scalaview Jul 25, 2017
@droberts-sea
Copy link
Collaborator

Example app that hits this bug: https://github.com/droberts-ada/rabl-test-app

The problem appears to be that in API mode all of the view functionality is stripped out, including all the code that glues together controllers and views. The reason that including the jbuilder gem works is they have a railtie to add a bunch of that back in:

rails/jbuilder@29c0014

Might be this is a pretty straightforward fix.

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 a pull request may close this issue.

3 participants