use from engine
Closed this issue · 2 comments
Hi, using rails 5.0.6 and latest gon, inside an engine, i try
gon.rabl
in an engine controller (as i understand the docs).
This tries to open the correctly named rabl template in my application.
Digging into the source i see that a file is being opened from the template name. But that open does not conform to rails view_path rules, ie opens in the apps root.
A simple fix, which works for me, is not to open the file and just pass the template name to rabl. Don't know about rabl-rails, but rabl searches view_paths correctly.
So in Gon::Rabl.parse_with_rabl
one just does not pass a source (instead nil) to the Rabl::Engine
and all is well.
It's a trivial change, but if you want (and are willing to accept) a pull request, let me know
ok, too quick. That just stopped the error, but rendered nothing.
Investigating more
I am moving to to_json, but this can be done without changing gon, by passing the full template name into .rabl
gon.rabl template: OfficeClerk::Engine.root.join("app/views/purchases/show.json")
maybe more a documentation issue. i'll close, since gon has grown to v6 without anyone else having this problem