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

ExtendedDocument views don't return documents with database set #9

Open
tapajos opened this issue Jul 2, 2010 · 1 comment
Open

Comments

@tapajos
Copy link
Member

tapajos commented Jul 2, 2010

Issue from: http://github.com/couchrest/couchrest/issues#issue/6

I'm not using the use_database(db) command in my ExtendedDocuments (just because I don't like globals that much). So I use :database => @db when accessing my views, but the ExtendedDocuments that are returned don't have their 'database' set, so I can't save or destroy them.

I have a patch if you want it, although I've only been using couchrest for a couple of days so I'm probably missing something...

@samlown
Copy link
Member

samlown commented Jul 2, 2010

The safest bet when doing this is to use the class proxy, that should automatically assign the database when the document is loaded.

Something I've had on my mind and I've yet to implement, is to add a "proxied_by" class method to the models. The idea would be that you define a Proxy model and add to it child models you'd like to load, eg "proxy_for :projects". To load you're projects you'd use an instance of your proxy and call: @company.projects, couchrest would handle the rest. If I manage to do this, it'll probably go into CouchRest Model.

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