Skip to content

Commit 160ed2e

Browse files
committed
added content_json to stories for story builder content
1 parent 310e75a commit 160ed2e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

app/models/story.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Story < ApplicationRecord
77

88
# As for the docs, `translates` goes BEFORE `friendly_id`
99
# see https://github.com/norman/friendly_id-globalize#translating-slugs-using-globalize
10-
translates :title, :content, :slug
10+
translates :title, :content, :content_json, :slug
1111
friendly_id :title, use: [:slugged, :history, :globalize] # keep this order, see https://stackoverflow.com/a/33652486/1897170
1212

1313
validates :title, :content, :place, presence: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class AddContentJsonToStories < ActiveRecord::Migration[5.1]
2+
def change
3+
add_column :stories, :content_json, :json
4+
5+
reversible do |dir|
6+
dir.up do
7+
Story.add_translation_fields! content_json: :json
8+
end
9+
10+
dir.down do
11+
remove_column :story_translations, :content_json
12+
end
13+
end
14+
end
15+
end

db/schema.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 20180202150659) do
13+
ActiveRecord::Schema.define(version: 20180305151647) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -88,6 +88,7 @@
8888
t.boolean "welfare_provision", default: false
8989
t.boolean "good_practice", default: false
9090
t.boolean "anonymous", default: false
91+
t.json "content_json"
9192
t.index ["anonymous"], name: "index_stories_on_anonymous"
9293
t.index ["commoner_id"], name: "index_stories_on_commoner_id"
9394
t.index ["good_practice"], name: "index_stories_on_good_practice"
@@ -110,6 +111,7 @@
110111
t.string "title"
111112
t.text "content"
112113
t.string "slug"
114+
t.json "content_json"
113115
t.index ["locale"], name: "index_story_translations_on_locale"
114116
t.index ["story_id"], name: "index_story_translations_on_story_id"
115117
end

0 commit comments

Comments
 (0)