nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 334 forks source link

Rabl partial lookup based on requested api namespace #720

Closed zauzaj closed 5 years ago

zauzaj commented 5 years ago

Hi all,

We have multiple apis with multiple versions, and what I want is to specify that rabl renders partials with requested path. So for example: When user requests for api/patients/v2/consultations/index, we're rendering views/api/patients/v2/consultations/index.rabl

In that rabl, we're doing partial 'motives/index', object: m and we get an error _Cannot find rabl template 'motives/index within registered (["MyUser/projects/myproject/app/views"] view paths!)

If I render partial like this: partial 'api/patients/v2/motives/index, object: m everything works good!

So what I want is to dynamically specify this part api/patients/v2/ as it will be always the same as request.url. And then simple partial motive/index it will knows to what app/views/api{resource}/{version}/motive/index.rabl should lookup.

Any idea?