From 81456a0637d5db710f716c54637bd107273c3f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Thu, 21 Oct 2021 12:33:02 +0200 Subject: [PATCH] communication posts : rich text for text --- app/models/communication/website/post.rb | 4 +++- app/views/admin/communication/website/posts/_form.html.erb | 4 ++-- ...11021095157_rename_text_in_communication_website_posts.rb | 5 +++++ db/schema.rb | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20211021095157_rename_text_in_communication_website_posts.rb diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index e7d4f3883..a3211613c 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -4,10 +4,10 @@ # # id :uuid not null, primary key # description :text +# old_text :text # published :boolean default(FALSE) # published_at :datetime # slug :text -# text :text # title :string # created_at :datetime not null # updated_at :datetime not null @@ -27,6 +27,8 @@ class Communication::Website::Post < ApplicationRecord include WithSlug + has_rich_text :text + belongs_to :university belongs_to :website, foreign_key: :communication_website_id diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index a55a613a0..3bf62603e 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -7,8 +7,8 @@ </div> <div class="card-body"> <%= f.input :title %> - <%= f.input :description, as: :trix_editor %> - <%= f.input :text, as: :trix_editor %> + <%= f.input :description %> + <%= f.input :text, as: :rich_text_area %> </div> </div> </div> diff --git a/db/migrate/20211021095157_rename_text_in_communication_website_posts.rb b/db/migrate/20211021095157_rename_text_in_communication_website_posts.rb new file mode 100644 index 000000000..da1a01846 --- /dev/null +++ b/db/migrate/20211021095157_rename_text_in_communication_website_posts.rb @@ -0,0 +1,5 @@ +class RenameTextInCommunicationWebsitePosts < ActiveRecord::Migration[6.1] + def change + rename_column :communication_website_posts, :text, :old_text + end +end diff --git a/db/schema.rb b/db/schema.rb index bb4be990c..fe55fba23 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_21_093238) do +ActiveRecord::Schema.define(version: 2021_10_21_095157) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -175,7 +175,7 @@ ActiveRecord::Schema.define(version: 2021_10_21_093238) do t.uuid "communication_website_id", null: false t.string "title" t.text "description" - t.text "text" + t.text "old_text" t.boolean "published", default: false t.datetime "published_at" t.datetime "created_at", precision: 6, null: false -- GitLab