Skip to content

Commit

Permalink
Minor doc / formatting tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
obrie committed Apr 14, 2009
1 parent 3640949 commit aa3e4e7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
12 changes: 4 additions & 8 deletions README.rdoc
Expand Up @@ -28,8 +28,7 @@ knowing the type of model your interacting with. For example, a typical
polymorphic assocation looks like the following:

class Tag < ActiveRecord::Base
belongs_to :taggable,
:polymorphic => true
belongs_to :taggable, :polymorphic => true
end

When getting the taggable record, you would normally have to call
Expand All @@ -45,19 +44,16 @@ class name.
=== Example

class Comment < ActiveRecord::Base
belongs_to :commentable,
:polymorphic => true
belongs_to :commenter,
:polymorphic => true
belongs_to :commentable, :polymorphic => true
belongs_to :commenter, :polymorphic => true
end

class Article < ActiveRecord::Base
has_many :comments, :as => :commentable
end

class User < ActiveRecord::Base
has_many :comments,
:as => :commenter
has_many :comments, :as => :commenter
end

c = Comment.find(1) # => #<Tag id: 1, commentable_id: 1, commentable_type: "Article", commenter_id: 1, commenter_type: "User"}>
Expand Down
3 changes: 1 addition & 2 deletions test/app_root/app/models/article.rb
@@ -1,5 +1,4 @@
class Article < ActiveRecord::Base
belongs_to :author
has_many :comments,
:as => :commentable
has_many :comments, :as => :commentable
end
3 changes: 1 addition & 2 deletions test/app_root/app/models/author.rb
@@ -1,6 +1,5 @@
class Author < ActiveRecord::Base
has_many :articles
has_many :pages
has_many :comments,
:as => :commenter
has_many :comments, :as => :commenter
end
8 changes: 3 additions & 5 deletions test/app_root/app/models/comment.rb
@@ -1,6 +1,4 @@
class Comment < ActiveRecord::Base
belongs_to :commentable,
:polymorphic => true
belongs_to :commenter,
:polymorphic => true
end
belongs_to :commentable, :polymorphic => true
belongs_to :commenter, :polymorphic => true
end
3 changes: 1 addition & 2 deletions test/app_root/app/models/page.rb
@@ -1,5 +1,4 @@
class Page < ActiveRecord::Base
belongs_to :author
has_many :comments,
:as => :commentable
has_many :comments, :as => :commentable
end
5 changes: 2 additions & 3 deletions test/app_root/app/models/user.rb
@@ -1,4 +1,3 @@
class User < ActiveRecord::Base
has_many :comments,
:as => :commenter
end
has_many :comments, :as => :commenter
end

0 comments on commit aa3e4e7

Please sign in to comment.