Skip to content

Commit 2ef37e1

Browse files
committed
MIGRATION: Add tables and models for Examples::Post
1 parent 5bc5156 commit 2ef37e1

19 files changed

+129
-1
lines changed

app/models/examples.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Examples
2+
def self.table_name_prefix
3+
"examples_"
4+
end
5+
end

app/models/examples/post.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Examples::Post < ApplicationRecord
2+
delegated_type :postable, types: %w[
3+
Examples::Posts::Markdown
4+
Examples::Posts::Link
5+
Examples::Posts::Image
6+
]
7+
end

app/models/examples/posts.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Examples::Posts
2+
def self.table_name_prefix
3+
"examples_posts_"
4+
end
5+
end

app/models/examples/posts/image.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Examples::Posts::Image < ApplicationRecord
2+
end

app/models/examples/posts/link.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Examples::Posts::Link < ApplicationRecord
2+
end

app/models/examples/posts/markdown.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Examples::Posts::Markdown < ApplicationRecord
2+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CreateExamplesPosts < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :examples_posts do |t|
4+
t.string :title, null: false
5+
t.references :postable, polymorphic: true, null: false
6+
7+
t.timestamps
8+
end
9+
end
10+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateExamplesPostsMarkdowns < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :examples_posts_markdowns do |t|
4+
t.text :body, null: false
5+
6+
t.timestamps
7+
end
8+
end
9+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateExamplesPostsLinks < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :examples_posts_links do |t|
4+
t.string :url, null: false
5+
6+
t.timestamps
7+
end
8+
end
9+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateExamplesPostsImages < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :examples_posts_images do |t|
4+
t.string :url, null: false
5+
6+
t.timestamps
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)