ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

Request to update 'Render object directly' wiki to include instructions for ensuring helpers are present #30

Closed john-bai closed 11 years ago

john-bai commented 11 years ago

I was following the 'Render object directly' wiki and it seems this method doesn't have access to view/path helpers. If it's possible to do so, could you include some sample code of how to include helpers in that direct call?

undefined method `user_path' for #<RablRails::Renderers::JSON:0x0000010530ec50>
ccocchi commented 11 years ago

@jtherrell Hmm if you need to include helpers, you need to add them to RablRails::Renderer::Context. So in your case, this should work

RablRails::Renderer::Context.send(:include, Rails.application.routes.url_helpers)