Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method 'html_safe' for nil: cached template.source missing #51

Open
mcary opened this issue Mar 28, 2015 · 1 comment
Open

Comments

@mcary
Copy link

mcary commented Mar 28, 2015

I'm running into trouble with sharing stache templates between server and client on Rails 4.2.0. Once the template is rendered on the server, I get this error when calling template_include_tag in the template:

  1) Some example
     Failure/Error: Unable to find matching line from backtrace
     ActionView::Template::Error:
       undefined method `html_safe' for nil:NilClass
     # ./app/views/pages/index.html.erb:3:in `_app_views_pages_index_html_erb__933758841857237125_70177580457500'

It looks like the problem is that when template_include_tag looks up the template and it was cached, template.source is nil. Based on the template refresh method, I gather this is intended, perhaps to keep the cache leaner.

The refresh method uses lookup_context.disable_cache to ensure the source is present. Doing the same inside of template_include_tag seems to fix the issue in my test case.

Would you like me to submit a pull request to address the issue that way? I don't have spec coverage for it within stache yet; I only have an integration test in my rails app that exercises the failure case.

@mcary
Copy link
Author

mcary commented May 23, 2015

I have a fix here, but no tests within stache yet:
https://github.com/mcary/stache/tree/fix-helper-with-caching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant