Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3538

store_in only works on base classes

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hello, I use up to date mongoid 4.0.0 master.

      I tried using the store_in macro.

      It seems to work fine on base classes:

      avril14th@avril14th-ubuntu:~/src/white/trunk$ rails c test
      Loading test environment (Rails 4.0.2)
      2.1.0 :001 > class Beta
      2.1.0 :002?> include Mongoid::Document
      2.1.0 :003?> store_in :collection => 'beats'
      2.1.0 :004?> end
      => {:collection=>"beats", :session=>:default, :database=>#<Proc:0x0000000163d6b0@/home/avril14th/.rvm/gems/ruby-2.1.0/bundler/gems/mongoid-5b0f031992cb/lib/mongoid/sessions/storage_options.rb:78 (lambda)>}
      2.1.0 :006 > b = Beta.new
      => #<Beta _id: 5304cd126176726c15000000, >

      now, using it on a derived class fails:

      2.1.0 :007 > class R < Beta
      2.1.0 :008?> store_in :collection => 'yeah'
      2.1.0 :009?> end
      Mongoid::Errors::InvalidStorageOptions:
      Problem:
      Invalid options passed to R.store_in: {:collection=>"yeah"}.
      Summary:
      The :store_in macro takes only a hash of parameters with the keys :database, :collection, or :session.
      Resolution:
      Change the options passed to store_in to match the documented API, and ensure all keys in the options hash are symbols.

      Is this a natural / desired behavior?

            Assignee:
            arthurnn Arthur Nogueira Neves
            Reporter:
            muichkine Olivier Milla
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: