Permalink
Browse files

move-membership-to-sidebar

## The view layer

We would like the list of project memberships to appear in a side-bar
on the project show page, so the page will now display two
collections: stories and memberships. We can tell Rapid that these are
the two collections we are interested in using Hobo's view hints.
Edit the project model like this:

SHOW_PATCH

Note that view hints are defined in the model.   This is not a great
place for them, but it is better than the alternatives.

It is very common for websites to present information in a hierarchy, and this `children` declaration tells Hobo about the hierarchy of your data. The order is significant; in this example `stories` is the 'main' child relationship, and `memberships` is secondary. The Rapid page generators use this information and place the `stories` collection in the main area of the page, and an aside section will be added for the `memberships`.

Refresh any project page and you should see the collection, which will be empty of course, in a side-bar.
  • Loading branch information...
bryanlarsen authored and iox committed Jun 3, 2013
1 parent d589d6b commit b5f0ea5ea29adbeff740c6c34843a21333387c7d
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/models/project.rb
View
@@ -11,7 +11,7 @@ class Project < ActiveRecord::Base
has_many :stories, :dependent => :destroy, :inverse_of => :project
- children :stories
+ children :stories, :memberships
belongs_to :owner, :class_name => "User", :creator => true, :inverse_of => :projects
has_many :memberships, :class_name => "ProjectMembership", :dependent => :destroy, :inverse_of => :project

0 comments on commit b5f0ea5

Please sign in to comment.