has_many association based on Views
Reported by Oleg Andreev | April 28th, 2008 @ 02:43 AM | in 0.0.3
Article = Meta.new do
has_many :comments
end
BlogPost = Meta.new do
has_many :comments
end
produces =>
View.define(:name => "has_many_comments") do |v|
def v.map(uuid, doc)
[ [ [doc['belongs_to'], doc['created_at']], doc ] ] if doc.is_a? Comment
end
end
Comment.new(... :belongs_to => some_article )
some_article.comments # => list of all comments
This view is compatible with all the comment containers, defined at any time.
Comments and changes to this ticket
-
Yurii Rashkovskii April 28th, 2008 @ 02:44 AM
- Assigned user set to Yurii Rashkovskii
-
Yurii Rashkovskii April 28th, 2008 @ 02:49 AM
While it might be interesting to do a single view for comments, I think we should pay attention to this kind of special cases later — and as for now we only need to create a view per association.
-
Yurii Rashkovskii April 28th, 2008 @ 02:59 AM
- State changed from new to open
started views-based-associations branch (http://github.com/yrashk/stroked...)
-
Yurii Rashkovskii April 28th, 2008 @ 11:34 AM
- State changed from open to duplicate
Duplicate to #15
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
StrokeDB is an embeddable distributed document database written in Ruby
People watching this ticket
Tags
Referenced by
- 15 Figure out how to organize views for associations // #14 had some useful code snippet but was resolved as ...