Dropping CouchRest::Model

72 views
Skip to first unread message

J. Chris Anderson

unread,
Jan 14, 2009, 2:10:03 AM1/14/09
to CouchRest
There is some good code in CouchRest::Model, but I don't think it fits
the core of what CouchRest is about, which is having a technically
strong CouchDB library thats ready to support other more complex code
on top of it.

I plan to spin CouchRest::Model out into it's own project, and then
encourage people to hack it as crazy as they wanna. I have no idea
what to call the standalone project. I don't think CouchRest should be
part of the name, because CouchRest is about being solid, and Model is
an experiment in making a Rails-like DSL around Couch views.

justindz

unread,
Jan 14, 2009, 8:08:52 AM1/14/09
to CouchRest
CouchCushion?

ZDZolton

unread,
Jan 14, 2009, 10:18:04 AM1/14/09
to CouchRest
I agree, since Model takes a very much uncolored Couch API and then
(necessarily) makes all kinds of assumptions on top of it.

I'm currently making a gem to walk a CouchRest result hash, walk down
recursively, and map the values (where appropriate) to persistence-
ignorant model types.

If anyone has any input, or would like to help me out, contact me.

I should have some public repos up soon: http://github.com/zdzolton

Samuel Flores

unread,
Jan 14, 2009, 10:29:28 AM1/14/09
to couc...@googlegroups.com
I liked it.

Samuel Flores

Maximus

unread,
Jan 14, 2009, 10:50:51 AM1/14/09
to CouchRest
I liked it too, but at the same time I effectively forgot that there
was more to CouchRest than CouchModel. So if it was refactored into a
separate project, so that we could (not saying "should") have multiple
ORMs built on top of CouchRest, I would not be opposed :)

On Jan 14, 7:29 am, Samuel Flores <samflo...@gmail.com> wrote:
> I liked it.
>
> Samuel Flores
>

J. Chris Anderson

unread,
Jan 14, 2009, 3:02:50 PM1/14/09
to CouchRest


On Jan 14, 7:50 am, Maximus <nanode...@gmail.com> wrote:
> I liked it too, but at the same time I effectively forgot that there
> was more to CouchRest than CouchModel.  So if it was refactored into a
> separate project, so that we could (not saying "should") have multiple
> ORMs built on top of CouchRest, I would not be opposed :)
>

Yes, I'd love to see the code from CR::Model get reused and
frankensteined into lots of alternative ways to use it.

There are already a few good "model" libraries based on CouchRest. I'm
hoping to see even more, as different application have wildly
different needs.

Chris

Matt Aimonetti

unread,
Jan 14, 2009, 3:10:39 PM1/14/09
to couc...@googlegroups.com
I played with a library that apparently might or might not become public.

The lib was divided in 3 parts:

- storage     (fork of CouchRest 0.9.15 without the orm side of things)
- model       (because not all models are documents)
- document (uses model and storage to deal with documents)

I really like how things are split up and it makes things easier to tweak. I hope the author will consider releasing the gems, but since he doesn't want to support it, that might never happen.

- Matt

Max Aller

unread,
Jan 14, 2009, 3:21:04 PM1/14/09
to couc...@googlegroups.com
>> "he doesn't want to support it"

That's what Github is for!  :)

Adam Groves

unread,
Jan 18, 2009, 6:05:06 PM1/18/09
to CouchRest
Hi Chris,

I'm getting a strange error with couchrest-0.12.2:

Try this out:

%w(rubygems couchrest).each {|g| require g}

class Foo < CouchRest::Model
use_database CouchRest.database!('http://127.0.0.1:5984/my-
database')
end

Foo.all
p Foo.design_doc.database



Running this code the first time returns an CouchRest::Database
instance, running it the second time (after the design doc has been
added) I get:

NoMethodError: undefined method `view' for nil:NilClass
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/design.rb:84:in `fetch_view'
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/design.rb:42:in `view'
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/model.rb:392:in `fetch_view'
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/model.rb:383:in `fetch_view_with_docs'
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/model.rb:346:in `view'
from /Library/Ruby/Gems/1.8/gems/jchris-couchrest-0.12.2/lib/
couchrest/core/model.rb:121:in `all'
from (irb):5
from :0

The second time around, saved returns true, saved gets saved (line 363
in model.rb) but it doesn't seem like the design_doc's database value
get's updated.

Cheers

Adam

Samuel Flores

unread,
Jan 18, 2009, 6:18:48 PM1/18/09
to couc...@googlegroups.com
I was getting the same error and solved the problem, but my notebook
crashed before I push the correction to Github.

The error is on the 'design.rb' file. The 'refresh_design_doc' method
does not assigns a value for the 'database' field and for self['_id']
when the view is already saved.

It's an easy correction, but I don't have access to code now. Hope
that you can see it ;)

Samuel Flores

Adam Groves

unread,
Jan 20, 2009, 7:12:54 PM1/20/09
to CouchRest
I switched over from dm-couch-adapter to couchrest about a month ago
for a project of mine and I then added some basic associations and
validations. I've since extracted the 2 libraries and bundled them
together with CouchRest::Model (implemented as a mixin) as CouchSurfer
which can be found here: http://github.com/addywaddy/couchsurfer.

I'd appreciate any comments, feedback etc.

On Jan 14, 8:10 am, "J. Chris Anderson" <jch...@gmail.com> wrote:

Zachary Zolton

unread,
Jan 20, 2009, 10:45:20 PM1/20/09
to couc...@googlegroups.com
Adam,

I've been wracking my brains on how to create literally this exact
thing, but you're obviously way better at this stuff than me... I may
likely start to use and contribute to your code immediately!

I actually just started last week, but if you'd like to see my meager
efforts, take a look here:
http://github.com/zdzolton

Please email me back directly, as I'm interested in learning the
inspirations behind your very concise code.


Cheers,

Zach
Reply all
Reply to author
Forward
0 new messages