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

update Digester.digest implementation to be compatible with Rails 5 #653

Closed lsylvester closed 8 years ago

lsylvester commented 8 years ago

When running with rails 5 and perform_caching = true I was getting the error uninitialized class variable @@cache in Rabl::Digester

It seems that the ActionView::Digester has been changed and was no longer compatible with the Rabl::Digester overrides.

This updates the digest implementation for raise 5 apps top not use the @@cache and copies across the pre_stored check because I think that any Rabl template could have the same issues as the rails partial templates.

nesquena commented 8 years ago

Thanks

databyte commented 8 years ago

hey @lsylvester - @domcleal created a Rails 5 fixture test over in PR #668 and I'm getting failures on this line:

finder.digest_cache[cache_key] = stored_digest = Digestor.new(name, finder, options).digest

(in his branch, it's currently located here: https://github.com/domcleal/rabl/blob/ruby-compatibility/lib/rabl/digestor/rails5.rb#L22)

In an interactive debug session, I basically get to Digestor.new and it throws wrong number of arguments (3 for 0) occured for Digestor.new(name, finder, options).digest. Which makes sense because the signature for that class is:

module Rabl
  class Digestor < ActionView::Digestor
    def self.digest(name:, finder:, **options)

The Rails 4.x Digestor is instantiated and takes in just options for digest. So that works.

The Rails 5 Digestor doesn't have an initializer and the 3rd parameter is actually the dependencies and not the options.

I assume it's not actually supposed to call itself recursively because you'd get:

Digestor.digest(name: name, finder: finder, dependencies: dependencies)
*** ThreadError Exception: deadlock; recursive locking

So any hints on how to get the digestor to work in a vanilla Rails 5 fixture app? Does the Digestor call work in Rails 5 for you?