Change attribute name to content
This commit is contained in:
@@ -64,6 +64,6 @@ class ArticlesController < ApplicationController
|
|||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
# Only allow a list of trusted parameters through.
|
||||||
def article_params
|
def article_params
|
||||||
params.require(:article).permit(:title, :text)
|
params.require(:article).permit(:title, :content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Article < ApplicationRecord
|
class Article < ApplicationRecord
|
||||||
has_rich_text :text
|
has_rich_text :text
|
||||||
|
has_rich_text :content
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
json.extract! article, :id, :title, :text, :created_at, :updated_at
|
json.extract! article, :id, :title, :content, :created_at, :updated_at
|
||||||
json.url article_url(article, format: :json)
|
json.url article_url(article, format: :json)
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= form.label :text %>
|
<%= form.label :content %>
|
||||||
<%= form.rich_text_area :text %>
|
<%= form.rich_text_area :content %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class CreateArticles < ActiveRecord::Migration[7.0]
|
|||||||
def change
|
def change
|
||||||
create_table :articles do |t|
|
create_table :articles do |t|
|
||||||
t.string :title
|
t.string :title
|
||||||
t.text :text
|
t.text :content
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ ActiveRecord::Schema.define(version: 2021_12_16_184103) do
|
|||||||
|
|
||||||
create_table "articles", force: :cascade do |t|
|
create_table "articles", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.text "text"
|
t.text "content"
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user