cache-money icon indicating copy to clipboard operation
cache-money copied to clipboard

incompatible with rubyamf?

Open linzhp opened this issue 16 years ago • 2 comments

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

linzhp avatar Jun 24 '09 05:06 linzhp

Are you using ActiveRecord SessionStore?

deedubs avatar Aug 18 '09 18:08 deedubs

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

linzhp avatar Aug 19 '09 01:08 linzhp