Skip to content

Commit

Permalink
move-membership-to-sidebar
Browse files Browse the repository at this point in the history
## 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 Aug 12, 2013
1 parent d589d6b commit b5f0ea5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/project.rb
Expand Up @@ -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
Expand Down

0 comments on commit b5f0ea5

Please sign in to comment.