Partial lookup constrained to :json format #280

Closed
tuscland opened this Issue Jul 2, 2012 · 8 comments

Comments

Projects
None yet
2 participants

tuscland commented Jul 2, 2012

When using partials with a custom mime type (e.g. "application/my_type_v1+json" registered for example as :my_type_v1), rabl forces the resolution of the partial to :json format.

See lib/rabl/partials.rb at line 74.

Instead it should use the format of the currently rendered template (i.e. :my_type_v1).

@databyte databyte closed this in 4513680 Jul 2, 2012

Collaborator

databyte commented Jul 2, 2012

Test out master and tell me if that resolves it for you.

tuscland commented Jul 2, 2012

Thank you for your swift reply!
I just tested, and the problem does not seem to be solved, at least not totally.

So:

  • I have registered my custom MIME type "application/my-type_v1+json" as :my_type_v1.
  • I have a template "show.my_type_v1.rabl", that uses a partial for example let's name it 'details'.
  • The file name of this partial' should be "_details.my_type_v1.rabl", but rabl requires me to use "_details.json.rabl".

I initially thought the fix you made would do the trick, but it does not work.
I walked the backtrace in search of how the format is passed to the engine, but I can't find how to solve this issue.

It appears that the 'root' template has the correct extension because Rails has the knowledge of the needed extension, however RABL does not and assume the source_format should be JSON.

Thanks for your help.

Collaborator

databyte commented Jul 2, 2012

Hmm, I changed the tests and when I requested the format :xml - it did seem to require a partial in the correct format.

Is there anyway for you to create a broken test in rabl itself or recreate the problem in a dummy public Rails app that I can access? I don't mind looking into it but I doubt I can recreate the problem as quickly as you can.

tuscland commented Jul 2, 2012

Here is a quick test: https://github.com/tuscland/rabl-custom-mime-types
Please have a look at file app/controlles/people_controller.rb for more info.

I just realized that the test here is not broken as you asked, only demonstrating the problem. if you want to break it rename _detail.json.rabl into _detail.rabl_test_v1.rabl

tuscland commented Jul 6, 2012

Hi databyte,
Could you please re-open this ticket as I don't think the issue has been solved.
Thanks!

@databyte databyte reopened this Jul 6, 2012

Collaborator

databyte commented Jul 6, 2012

Sure, I'll look at it in more detail tomorrow.

tuscland commented Jul 6, 2012

Thanks!

Collaborator

databyte commented Jul 9, 2012

Alrighty - try out master again. Tell me if that works or not.

@tuscland tuscland closed this Jul 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment