Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

has_many association based on Views

#14
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.

Reported by Oleg Andreev · April 27th, 2008 @ 11:43 PM

State: duplicate
Milestone: 0.0.3
Assigned to: Yurii Rashkovskii Yurii Rashkovskii

Activity

  1. Yurii Rashkovskii
    Yurii Rashkovskii
    • Assigned user set to Yurii Rashkovskii

    April 27th, 2008 @ 11:44 PM

  2. Yurii Rashkovskii
    Yurii Rashkovskii

    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.

    April 27th, 2008 @ 11:49 PM

  3. Yurii Rashkovskii
    Yurii Rashkovskii
    • State changed from new to open

    started views-based-associations branch (http://github.com/yrashk/stroked...)

    April 27th, 2008 @ 11:59 PM

  4. Yurii Rashkovskii

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.