Skip to content

Commit 00951f7

Browse files
committed
Remove Author and Authorship as models and replace them with polymorphic/direct relations on Authorable and concerns
1 parent 259c204 commit 00951f7

File tree

16 files changed

+48
-97
lines changed

16 files changed

+48
-97
lines changed

app/models/better_together/author.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/models/better_together/authorable.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/models/better_together/authorship.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
module BetterTogether
44
# Connects an author (eg: person) to an authorable (eg: post)
55
class Authorship < ApplicationRecord
6-
belongs_to :author
7-
belongs_to :authorable
6+
include Positioned
7+
8+
belongs_to :author,
9+
class_name: 'BetterTogether::Person'
10+
belongs_to :authorable,
11+
polymorphic: true
812
end
913
end

app/models/better_together/page.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module BetterTogether
44
# An informational document used to display custom content to the user
55
class Page < ApplicationRecord
6-
include AuthorableConcern
6+
include Authorable
77
include Categorizable
88
include Identifier
99
include Protected

app/models/better_together/person.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.primary_community_delegation_attrs
99
[]
1010
end
1111

12-
include AuthorConcern
12+
include Author
1313
include Contactable
1414
include FriendlySlug
1515
include Identifier

app/models/better_together/post.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Post < ApplicationRecord
88
public: 'public'
99
}.freeze
1010

11-
include AuthorableConcern
11+
include Authorable
1212
include FriendlySlug
1313
include Categorizable
1414
include Identifier

app/models/concerns/better_together/author_concern.rb renamed to app/models/concerns/better_together/author.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module BetterTogether
44
# When included, designates a class as Author
5-
module AuthorConcern
5+
module Author
66
extend ActiveSupport::Concern
77

88
included do

app/models/concerns/better_together/authorable_concern.rb renamed to app/models/concerns/better_together/authorable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module BetterTogether
44
# When included, designates a class as Authorable
5-
module AuthorableConcern
5+
module Authorable
66
extend ActiveSupport::Concern
77

88
included do

db/migrate/20200520035111_create_better_together_authors.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

db/migrate/20200520035112_create_better_together_authorables.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)