nkallen / cache-money

A Write-Through Cacheing Library for ActiveRecord
Apache License 2.0
994 stars 107 forks source link

incompatible with rubyamf? #5

Open linzhp opened 15 years ago

linzhp commented 15 years ago

I feel cache_money is great, especially for its support of transaction. I haven't seen any others provide such feature. However, I need to use rails as the backend of a Flex project, and use rubyamf (http://code.google.com/p/rubyamf/) to communicate with the front side. When an ActiveRecord (e.g. User) is configured with class mapping:

  ClassMappings.register(
  :actionscript => 'model.UserModel',
  :ruby => 'User',
  :type => 'active_record',
  :attributes => ["id", "name"],
  :associations  =>{ :for_default=>[] })

User.find 1 reports some error: NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.indices from (DELEGATION):2:in __send__' from (__DELEGATION__):2:inindices' from (DELEGATION):2:in __send__' from (__DELEGATION__):2:inindices' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:114:in indexed_on?' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:56:incacheable?' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:15:in perform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/primary_key.rb:17:inperform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/query/abstract.rb:7:in perform' from /home/clive/ruby/RailsApplication1/vendor/plugins/nkallen-cache-money/lib/cash/finders.rb:29:infind_from_ids' from /home/clive/ruby/RailsApplication1/vendor/rails/activerecord/lib/active_record/base.rb:590:in `find' from (irb):1

and index [:name] in User class also reports: home/clive/ruby/RailsApplication1/vendor/rails/activerecord/lib/active_record/base.rb:1833:in method_missing':NoMethodError: undefined methodindex' for #Class:0xb730f374

I couldn't find a way to attach the rails project I created here. If some one has problem in reproduce the issue, feel free to contact me

deedubs commented 14 years ago

Are you using ActiveRecord SessionStore?

linzhp commented 14 years ago

Thanks for your reply. I've figured out the problem. Rubyamf needs to be loaded after cache_money, otherwise cache_money won't be able to override ActiveRecord