Closed whittle closed 10 years ago
Thanks, Jason - they changed the stack in Rails 4.1. I have to look into that anyway so maybe I can fix it soon.
Is there a list of things that need to be done, or is this more in the discovery phase?
To make it work only a few lines of code in roar-rails should be necessary.
On Wed, May 7, 2014 at 12:26 AM, Jason Whittle notifications@github.comwrote:
Is there a list of things that need to be done, or is this more in the discovery phase?
— Reply to this email directly or view it on GitHubhttps://github.com/apotonick/roar-rails/issues/65#issuecomment-42308615 .
In Rails 4.1, you need to manually register a global HAL renderer.
ActionController.add_renderer :hal do |js, options|
self.content_type ||= Mime::HAL
js.to_json
end
I did not add this to roar-rails as I don't understand what it does and I don't wanna make people's code break.
The responder/renderer layer in Rails needs a redesign, I might try to provide an alternative simplified implementation in roar-rails/Trailblazer soon. The fact that renderers set Content-type
, check if objects respond to to_json
and the like is simply wrong (see discussion here).
I created 2 new Rails apps with the standard settings, one with Rails v.4.0.4 and the other with Rails v.4.1.0. In both, I changed the Gemfile to use roar-rails instead of jbuilder and ran
bundle
. Then, I applied the changes detailed at https://gist.github.com/whittle/76df2f1799713977ea4d to both apps, ranbundle exec rails server
and queried them withcurl -H "Accept: application/hal+json" http://localhost:3000/site_faqs/1
The Rails v.4.0.4 app correctly responds with a JSON document. The Rails v.4.1.0 app throws the exception
ActionController::MissingRenderer (No renderer defined for format: hal)