Skip to content
Browse files

Updating documentation.

  • Loading branch information...
1 parent 82aebae commit e350fee03f755673cda5153ac6a2241e7ed3094a @andrewculver andrewculver committed
Showing with 13 additions and 4 deletions.
  1. +13 −4 README.md
View
17 README.md
@@ -1,16 +1,16 @@
# inherits_many
## Summary
-Allow many-to-many relationships to inherit associated objects from a parent object's has_many association.
+Allow many-to-many relationships to inherit associated objects from a parent object's `has_many` association.
## Installation
Add the following to your `Gemfile`:
- gem 'inherits_many'
+ gem 'inherits_many'
## Usage Example
-An individual restaurant can have many menu items, but a restaurant that belongs to a chain inherits all it's menu items from the chain it belongs to.
+An individual restaurant can have many menu items, but a restaurant that belongs to a chain inherits all it's menu items from the chain it belongs to. The behaviors we want include:
* When a restaurant joins a chain, it gets a copy of all the menu items from that chain.
* When a restaurant leaves a chain, all those menu items go away.
@@ -29,13 +29,22 @@ The ActiveRecord associations and `inherits_many` definition look like this:
has_many :restaurants, through: :restaurant_menu_items
belongs_to :chain
+ # Syntax for this gem.
passes_on_to :restaurants, of: :chain
+
end
class Restaurant < ActiveRecord::Base
has_many :restaurant_menu_items
has_many :menu_items, through: :restaurant_menu_items
belongs_to :chain
-
+
+ # Syntax for this gem.
inherits_many :menu_items, from: :chain
+
end
+
+ class RestaurantMenuItem < ActiveRecord::Base
+ belongs_to :restaurant
+ belongs_to :menu_item
+ end

0 comments on commit e350fee

Please sign in to comment.
Something went wrong with that request. Please try again.