alexeypetrushin/mongodb_model — Issue #3: Error when passing collection name on save
Author: joefiorini
Created: 2012-01-05 04:45:52+00:00
State: open

When I have a model such as:

```ruby
class Unit
inherit Mongo::Model

attr_accessor :name, :status, :stats

def inspect; name end

end
```
If I call save like:

```ruby
p zeratul.save(collection: :units)
```

I get the error:

```
/Users/joe/.rbenv/versions/1.9.3-p0/gemsets/mongodb_model_spike/gems/mongodb_model-2.1.1/lib/mongo/model/crud.rb:29:in `block in save': undefined method `save' for :units:Symbol (NoMethodError)
from /Users/joe/.rbenv/versions/1.9.3-p0/gemsets/mongodb_model_spike/gems/mongodb_model-2.1.1/lib/mongo/model/crud.rb:108:in `call'
from /Users/joe/.rbenv/versions/1.9.3-p0/gemsets/mongodb_model_spike/gems/mongodb_model-2.1.1/lib/mongo/model/crud.rb:108:in `with_collection'
from /Users/joe/.rbenv/versions/1.9.3-p0/gemsets/mongodb_model_spike/gems/mongodb_model-2.1.1/lib/mongo/model/crud.rb:28:in `save'
```
I realize I can set the collection name via a class method on the model, but I'd like to eventually be able to extend my POROs at runtime with Model::Model and then save.