Leave it as a memo for yourself.
Create an app using MySQL.
$ rails new actionText -d mysql
Go to the created app
2.scaffold Create an app template with scaffold.
$ rails g scaffold article title:string
$ rails db:create
4.migrate
$ rails db:migrate
$ rails action_text:install
6.migrate
$ rails db:migrate
Since Action Text data is stored in a dedicated table, it needs to be associated with the article model.
app/models/article.rb
class Article < ApplicationRecord
has_rich_text :content
end
rhtml:app/views/articles/_form.html.erb
#abridgement
<div class="field">
<%= form.label :title %>
<%= form.text_field :title %>
<%= form.label :content %>
<%= form.rich_text_area :content %>
</div>
#abridgement
rhtml:app/views/articles/show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Content:</strong>
<%= @article.content %>
</p>
<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
Add content to the method that reads the params parameter.
app/controllers/articles_controller.rb
#abridgement
def article_params
params.require(:article).permit(:title, :content)
end
#abridgement
10.image_processing No image is displayed without image_processing.
gem 'image_processing'
$ bundle install
End
Recommended Posts