Skip to content

Commit

Permalink
README update
Browse files Browse the repository at this point in the history
  • Loading branch information
Winton Welsh committed Aug 4, 2008
1 parent 5225dee commit ce7d30d
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ Install
rake db:migrate


Model
-----

class User < ActiveRecord::Base
acts_as_relationable :books
end

class Book < ActiveRecord::Base
acts_as_relationable :users
end


Controller
----------

Expand All @@ -27,22 +39,12 @@ Controller
u.books # [ b ]
b.users # [ u ]


Model
-----

class User < ActiveRecord::Base
acts_as_relationable :books
end

class Book < ActiveRecord::Base
acts_as_relationable :users
end

### Self referential relationships
Self referential relationships
------------------------------

class User < ActiveRecord::Base
acts_as_relationable :users
acts_as_relationable :users
end

u = User.create
Expand All @@ -53,7 +55,7 @@ Model
Relationship-specific fields
----------------------------

I want users to be able to 'friend' and 'best friend' each other.
Say you want users to be able to 'friend' and 'best friend' each other.

### Run the generator

Expand All @@ -63,12 +65,12 @@ I want users to be able to 'friend' and 'best friend' each other.
### Model

class User < ActiveRecord::Base
acts_as_relationable :users, :fields => [ :friend, :best_friend ]
acts_as_relationable :users, :fields => [ :friend, :best_friend ]

self.child_users.first.update_attribute :friend, true
self.child_users.first.friend? # == true
self.child_users.first.best_friend? # == false
self.child_users.friends # [ self.child_users.first ]
self.child_users.first.update_attribute :friend, true
self.child_users.first.friend? # == true
self.child_users.first.best_friend? # == false
self.child_users.friends # [ self.child_users.first ]
end


Expand Down

0 comments on commit ce7d30d

Please sign in to comment.