If I have an action in my controller like the following:
class PatientsController < ApplicationController
Started GET "/api/patients/368.json" for 127.0.0.1 at 2013-01-18 09:58:40 -0500
Processing by PatientsController#show as JSON
Patient Load (7.5ms) SELECT "patients".* ...
Completed 500 Internal Server Error in 1018ms
ActionView::Template::Error (ReferenceError: Can't find variable: define):
1: - patient = @model
If I put a rabl template at app/views/patients/show.json.rabl, then it works okay.
Oops, that's no good :P Looks like a bug with the ActionView template handler. Please use the gem version 1.9.1 until fixed.
@jimmycuadra Can you have a look at this?
I'm investigating this, but haven't found the solution yet. For a quick, temporary fix:
In config/initializers/mime_types.rb, add:
Mime::Type.register_alias "text/html", :hamlc
Change the name of the view file to show.hamlc.hamlc.
I hope to have a non-hack solution soon.
Thanks a lot for having a look and keeping us updated.
Thanks, as @netzpirat suggested I am using 1.9.1 without issues.
@netzpirat AFAICT a template file which does not specify a MIME type will be used for all MIME types if a MIME-type-specific template is not found. It may be necessary for templates shared between Rails and Sprockets to use the action.format.handler convention.
Add custom resolver to prevent Rails from rendering Haml Coffee templ…
…ates for non-HTML formats. Fixes #80.
Figured out how to do this by using a custom ActionView::Resolver to do the template lookup for the templates directory. :D
Thanks a lot for the nice fix @jimmycuadra! Version 1.11.0 released.
Thanks! I've updated and all looks good.