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

ActiveRecord mixin - incorrect initializer code, and dumping problems #37

Open
skwp opened this issue Jun 20, 2013 · 3 comments
Open

ActiveRecord mixin - incorrect initializer code, and dumping problems #37

skwp opened this issue Jun 20, 2013 · 3 comments

Comments

@skwp
Copy link

skwp commented Jun 20, 2013

@fancyremarker When I add the code to the initializer,

/Users/yan/dev/reverb/config/initializers/garner.rb:4:in `<module:ActiveRecord>': Base is not a module (TypeError)

Which is because Base is actually a Class. The correct initializer code is:

require "garner/mixins/active_record"

module ActiveRecord
  class Base
    include Garner::Mixins::ActiveRecord::Base
  end
end

Note the require line, and the use of class Base. I can make a pull request for that, but I'm afraid there are other issues.

But then I run into further problems when actually trying to cache that resources:
no _dump_data is defined for class Proc

/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/rspec-mocks-2.12.2/lib/rspec/mocks/extensions/marshal.rb:5:in `dump'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/rspec-mocks-2.12.2/lib/rspec/mocks/extensions/marshal.rb:5:in `dump_with_mocks'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:561:in `initialize'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:363:in `new'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:363:in `block in write'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:520:in `instrument'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:362:in `write'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/gems/activesupport-3.2.12/lib/active_support/cache.rb:299:in `fetch'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/bundler/gems/garner-b880202c454c/lib/garner/cache.rb:12:in `fetch'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/bundler/gems/garner-b880202c454c/lib/garner/cache/identity.rb:16:in `fetch'
/Users/yan/.rvm/gems/ruby-1.9.3-p392@reverb/bundler/gems/garner-b880202c454c/lib/garner/cache/identity.rb:24:in `bind'
fancyremarker pushed a commit to fancyremarker/garner that referenced this issue Jun 20, 2013
@fancyremarker
Copy link
Contributor

Thanks @skwp! I fixed the README in master with your corrected initializer code; as for the _dump_data exception, how are you reaching that? Here's an example of how I'm testing the ActiveRecord binding functionality locally, FWIW:

class App
  include Garner::Cache::Context  
end    

class Activist < ActiveRecord::Base    
end        
puts (activist = Activist.create({ :name => "Ahab" }))
#<Activist:0x007fa2d3d62d38>

puts Garner.config.binding_key_strategy
# >> Garner::Strategies::Binding::Key::SafeCacheKey

app = App.new
puts app.garner.bind(activist) { SecureRandom.hex }
# >> 505c56ab034c92021d8a4477f1e97e30
puts app.garner.bind(activist) { SecureRandom.hex }
# >> 505c56ab034c92021d8a4477f1e97e30

activist.touch
puts app.garner.bind(activist) { SecureRandom.hex }
# >> cee0b8f65df24fc21961fcb32a5dc27f

@fancyremarker
Copy link
Contributor

(That particularly example is using an instance of ActiveSupport::Cache::MemoryStore for Garner.config.cache.)

@skwp
Copy link
Author

skwp commented Jun 20, 2013

Thanks, that will help me debug. I have to run for now but I will get back to you later.

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

2 participants