{"id":23804,"date":"2019-12-19T08:00:37","date_gmt":"2019-12-18T23:00:37","guid":{"rendered":"https:\/\/www.techscore.com\/blog\/?p=23804"},"modified":"2019-12-13T09:59:55","modified_gmt":"2019-12-13T00:59:55","slug":"ruby-on-rails-6-action-text","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2019\/12\/19\/ruby-on-rails-6-action-text\/","title":{"rendered":"Ruby on Rails 6.0\u306eAction Text\u3092\u89e6\u3063\u3066\u307f\u305f\u3002"},"content":{"rendered":"
\u3053\u308c\u306f \ud83d\ude3aTECHSCORE Advent Calendar 2019\ud83d\ude3a<\/a>\u306e19\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n \u4eca\u5e74\u306e8\u6708\u306bRuby on Rails(\u4ee5\u4e0bRails)\u306e\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u306a\u308b 6.0 \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002 \u3044\u304f\u3064\u304b\u65b0\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001 <\/p>\n Action Text \u306f\u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3001\u7de8\u96c6\u3001\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/strong><\/p>\n (\u516c\u5f0f\u30d6\u30ed\u30b0\u306e\u5185\u5bb9\u3092\u610f\u8a33) \u3059\u306a\u308f\u3061\u300cHTML\u3084CSS\u306e\u77e5\u8b58\u304c\u306a\u304f\u3066\u3082\u6587\u7ae0\u306e\u4fee\u98fe\u3084\u753b\u50cf\u306e\u633f\u5165\u306a\u3069\u304c\u3067\u304d\u308b\u30a8\u30c7\u30a3\u30bf\u300d \u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u81ea\u4f53\u306f\u3001\u3082\u3068\u3082\u3068gem(Ruby\u306e\u30e9\u30a4\u30d6\u30e9\u30ea)\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u305f\u3088\u3046\u3067\u3059\u304c\u3001 \u305d\u308c\u3067\u306f\u3001\u5b9f\u969b\u306bAction Text \u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n Rails\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u306a\u3069\u306f\u3001\u516c\u5f0f\u30ac\u30a4\u30c9<\/a>\u306b\u304a\u4efb\u305b\u3057\u307e\u3059\u306e\u3067\u3001 <\/p>\n \u753b\u50cf\u3092\u6271\u3046\u305f\u3081\u306b ImageMagick \u3092OS\u5074\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002 <\/p>\n \u6b21\u306bRails\u3067ImageMagick\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n Gemfile<\/p>\n \u4e0a\u8a18\u4fdd\u5b58\u5f8c\u3001bundle install\u3092\u3057\u307e\u3059\u3002<\/p>\n <\/p>\n \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u3057\u307e\u3059\u3002<\/p>\n <\/p>\n \u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u306f\u3067\u304d\u305f\u306e\u3067\u3001\u30e2\u30c7\u30eb\u3084\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3001\u30d3\u30e5\u30fc\u306b\u8a2d\u5b9a\u3092\u66f8\u304d\u52a0\u3048\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n app\/models\/playground.rb<\/p>\n app\/controllers\/playgrounds_controller.rb<\/p>\n app\/views\/playgrounds\/_form.html.erb<\/p>\n app\/views\/playgrounds\/show.html.erb<\/p>\n \u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001\u8907\u96d1\u306a\u8a2d\u5b9a\u3092\u884c\u308f\u305a\u306b\u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8\u3092\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002 Action Text \u3067\u63d0\u4f9b\u3055\u308c\u308b\u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u306f Trix \u3068\u547c\u3070\u308c\u308b\u3082\u306e\u304c\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002 trix\u306eCSS<\/a>\u3092\u3082\u3068\u306b\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n app\/assets\/stylesheets\/actiontext.scss<\/p>\n \u203b\u30dc\u30bf\u30f3\u753b\u50cf\u306fapp\/assets\/images \u4ee5\u4e0b\u306b\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002 <\/p>\n \u4eca\u56de\u306fRails 6.0 \u306e\u65b0\u6a5f\u80fd\u3067\u3042\u308b Action Text \u306e\u57fa\u672c\u7684\u306a\u3068\u3053\u308d\u306b\u3064\u3044\u3066\u89e6\u308c\u307e\u3057\u305f\u3002 \u305f\u3060\u3057\u4eca\u56de\u89e6\u308c\u305f\u3082\u306e\u306f\u3042\u304f\u307e\u3067\u3082\u57fa\u672c\u3060\u3051\u3067\u3059\u306e\u3067\u3001 \u3053\u308c\u306f \ud83d\ude3aTECHSCORE Advent Calendar 2019\ud83d\ude3a\u306e19\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n \u4eca\u5e74\u306e8\u6708\u306bRuby on Rails(\u4ee5\u4e0bRails)\u306e\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u306a\u308b 6.0 \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002
\nRails\u306fTECHSCORE\u30d6\u30ed\u30b0\u3067\u4f55\u5ea6\u304b\u53d6\u308a\u4e0a\u3052\u3066\u3044\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<\/p>\n
\n\u305d\u306e\u4e2d\u3067 Action Text \u3068\u3044\u3046\u6a5f\u80fd\u304c\u9762\u767d\u305d\u3046\u3060\u3063\u305f\u305f\u3081\u89e6\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\u3010\u5b9f\u884c\u74b0\u5883\u3011\n\nOS \uff1aCentOS 7.6 \u2026 Windows10\u4e0a\u306bOracle VM VirtualBox\u3092\u5c0e\u5165\u3057\u3066\u5b9f\u884c\nRuby \uff1a2.6.3\nRails \uff1a6.0.1\n<\/pre>\n
Action Text \u3068\u306f<\/h2>\n
\nhttps:\/\/weblog.rubyonrails.org\/2018\/10\/3\/introducing-action-text-for-rails-6\/<\/a><\/p><\/blockquote>\n
\n\u304c\u63d0\u4f9b\u3055\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
\n\u4eca\u56de\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u3067\u672c\u4f53\u306b\u7d44\u307f\u8fbc\u307e\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002
\n <\/p>\nAction Text \u3092\u4f7f\u3063\u3066\u307f\u308b\u3002<\/h2>\n
\nrails new(Rails\u30a2\u30d7\u30ea\u306e\u3072\u306a\u578b\u3092\u4f5c\u308b\u30b3\u30de\u30f3\u30c9)\u3067\u751f\u6210\u3055\u308c\u305f\u30a2\u30d7\u30ea\u3092\u3082\u3068\u306b
\n\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u88c5\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n# CRUD\u6a5f\u80fd\u8ffd\u52a0(playground \u306f\u30e2\u30c7\u30eb\u540d\u3067\u3059)\nrails g scaffold playground\n\n# action_text\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nrails action_text:install\n\n<\/pre>\n
\n\u53c2\u8003\uff1ahttps:\/\/imagemagick.org\/script\/download.php<\/a><\/p>\n# lib\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nyum install https:\/\/imagemagick.org\/download\/linux\/CentOS\/x86_64\/ImageMagick-libs-7.0.9-8.x86_64.rpm\n\n# \u672c\u4f53\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nyum install https:\/\/imagemagick.org\/download\/linux\/CentOS\/x86_64\/ImageMagick-7.0.9-8.x86_64.rpm\n<\/pre>\n
\n# \u4ee5\u4e0b\u306e\u884c\u304c\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u5916\u3057\u3066\u4fdd\u5b58\u3059\u308b\u3002\ngem 'image_processing', '~> 1.2'\n<\/pre>\n
\nbundle install\n<\/pre>\n
\nrake db:migrate\n<\/pre>\n
class Playground < ApplicationRecord\n has_rich_text :content\nend\n<\/pre>\n
def playground_params\n params.require(:playground).permit(:content)\nend\n<\/pre>\n
# \u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u304c\u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u9069\u5207\u306a\u5834\u6240\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\n
\n# \u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u304ccontent(=\u30ea\u30c3\u30c1\u30c6\u30ad\u30b9\u30c8)\u3092\u8868\u793a\u3059\u308b\u7b87\u6240\u306b\u306a\u308a\u307e\u3059\u3002\n<%= @playground.content %>\n<\/pre>\n
\n
\n\u3053\u3053\u307e\u3067\u5b9f\u65bd\u3059\u308c\u3070\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059\u3002
\nrails s \u306a\u3069\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d0\u3092\u7acb\u3061\u4e0a\u3052\u3066\u78ba\u304b\u3081\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n
\n<\/a>
\n\u203b \u753b\u50cf\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u52d5\u304d\u307e\u3059\u3002<\/p>\n
\n
\n <\/p>\n\u30a8\u30c7\u30a3\u30bf\u3092\u3061\u3087\u3063\u3068\u3044\u3058\u3063\u3066\u307f\u308b\u3002<\/h2>\n
\n\u516c\u5f0f\u306b\u3088\u308b\u3068\u898b\u305f\u76ee\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u308b\u3089\u3057\u3044\u306e\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n
\n<\/a><\/p>\n
\n
\naction_text\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u969b app\/assets\/stylesheets \u30d5\u30a9\u30eb\u30c0\u4ee5\u4e0b\u306b
\nactiontext.scss \u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u7de8\u96c6\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n \ntrix-editor {\n border: 5px outset #bbb;\n}\n\ntrix-toolbar .trix-button--icon-bold::before {\n background-image: url(bold.png); \n}\n\ntrix-toolbar .trix-button--icon-italic::before {\n background-image: url(italic.png); \n}\n\ntrix-toolbar .trix-button--icon-strike::before {\n background-image: url(strike.png); \n}\n\ntrix-toolbar .trix-button--icon-link::before {\n background-image: url(link.png); \n}\n\n<\/pre>\n
\n
\n\u8a66\u3057\u3066\u307f\u305f\u7d50\u679c\u304c\u3053\u3061\u3089\u3067\u3059\u3002
\n\u4eca\u56de\u306f\u5165\u529b\u6b04\u306e\u67a0\u3068\u30dc\u30bf\u30f3\u306e\u753b\u50cf\u3092\u5909\u66f4\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n
\n<\/a><\/p>\n
\n\u307e\u3068\u3081<\/h2>\n
\n\u516c\u5f0f\u304b\u3089\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u3060\u3051\u3042\u3063\u3066\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u3001\u69d8\u3005\u306a\u5fdc\u7528\u304c\u5229\u304d\u305d\u3046\u306a\u6a5f\u80fd\u3060\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n
\n\u5b9f\u52d9\u3067Action Text \u3092\u4f7f\u3046\u305f\u3081\u306b\u306f\u3001\u3055\u3089\u306b\u7406\u89e3\u3092\u6df1\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[332,18],"tags":[141,22],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23804"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=23804"}],"version-history":[{"count":61,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23804\/revisions"}],"predecessor-version":[{"id":24956,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23804\/revisions\/24956"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=23804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=23804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=23804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}