Skip to content

Commit 0d9af29

Browse files
committed
Add polymorphic votes to playground
1 parent 4fa81a9 commit 0d9af29

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

playground/blog/fixtures.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,19 @@
5151
post :tdd_guide
5252
author :brad
5353
end
54+
55+
vote :alice_likes_hello do
56+
votable post(:hello_world)
57+
voter :alice
58+
end
59+
60+
vote :brad_likes_tdd do
61+
votable post(:tdd_guide)
62+
voter :brad
63+
end
64+
65+
vote :charlie_likes_great_post do
66+
votable comment(:great_post)
67+
voter :charlie
68+
end
5469
end

playground/blog/schema.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313
table :tags, singular: :tag, columns: [:name]
1414

1515
join_table :posts_tags, :posts, :tags
16+
17+
table :votes, singular: :vote, columns: [:votable_id, :votable_type, :voter_id] do
18+
polymorphic :votable
19+
belongs_to :voter, table: :users
20+
end
1621
end

0 commit comments

Comments
 (0)