{"id":346271,"date":"2023-03-04T21:01:49","date_gmt":"2023-03-04T21:01:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346271"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346271","title":{"rendered":"<span>ActionText \u0432 Ruby on Rails. \u041e\u0431\u0437\u043e\u0440 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/p>\n<p><a href=\"#goal\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043b\u044c<\/a><br \/><a href=\"#generated\" rel=\"noopener noreferrer nofollow\">\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b<\/a><br \/><a href=\"#how-model-links-to-active-text\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c ActionText \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 action_text_rich_texts<\/a><br \/><a href=\"#how-active_storage_blobs-save-files\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b\/\u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0432 \u0437\u0430\u043f\u0438\u0441\u044f\u0445<\/a><br \/><a href=\"#end\" rel=\"noopener noreferrer nofollow\">\u0418\u0442\u043e\u0433\u043e<\/a><\/p>\n<p><a class=\"anchor\" name=\"goal\" id=\"goal\"><\/a><\/p>\n<h3>\u0426\u0435\u043b\u044c<\/h3>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 &#8212; \u0447\u0430\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0421\u0443\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 &#8212; \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0430\u0439\u0442.<\/p>\n<p>\u0412\u00a0<a href=\"https:\/\/rubyonrails.org\/\" rel=\"noopener noreferrer nofollow\">Ruby on Rails<\/a>\u00a0\u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<a href=\"https:\/\/api.rubyonrails.org\/classes\/ActionText.html\" rel=\"noopener noreferrer nofollow\">ActionText<\/a>\u00a0\u0441\u00a0<a href=\"https:\/\/guides.rubyonrails.org\/action_text_overview.html\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 Rails. \u041e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u00a0<a href=\"https:\/\/trix-editor.org\/\" rel=\"noopener noreferrer nofollow\">Trix<\/a>. \u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 JavaScript, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430) \u0438 \u0440\u0438\u0441\u0443\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2f7\/86b\/927\/2f786b92718caf74829c199437b2c275.png\" alt=\"Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\" title=\"Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\" width=\"861\" height=\"682\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f7\/86b\/927\/2f786b92718caf74829c199437b2c275.png\"\/><\/p>\n<div><figcaption>Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043d\u0438\u0436\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Note<\/code>, \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 (show\/edit\/new.html.erb), \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p><a class=\"anchor\" name=\"generated\" id=\"generated\"><\/a><\/p>\n<h3>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>Action Text<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">bin\/rails action_text:install<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3dd\/b60\/967\/3ddb60967d976b21ad508c41df89c726.png\" alt=\"\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\" title=\"\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\" width=\"667\" height=\"392\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3dd\/b60\/967\/3ddb60967d976b21ad508c41df89c726.png\"\/><\/p>\n<div><figcaption>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u041f\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0438 \u0443\u0437\u043d\u0430\u0435\u043c:<\/p>\n<h4>1. Gemfile, Gemfile.lock<\/h4>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0433\u0435\u043c <a href=\"https:\/\/github.com\/janko\/image_processing\" rel=\"noopener noreferrer nofollow\"><u>image_processing<\/u><\/a>. \u042d\u0442\u043e\u0442 \u043f\u0430\u043a\u0435\u0442 \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c (\u0441\u0436\u0438\u043c\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440) \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442. \u042d\u0442\u043e\u0442 \u0433\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438\u0431\u043e <a href=\"https:\/\/www.imagemagick.org\/\" rel=\"noopener noreferrer nofollow\">ImageMagick<\/a>\/<a href=\"https:\/\/www.imagemagick.org\/\" rel=\"noopener noreferrer nofollow\">GraphicsMagick<\/a>, \u043b\u0438\u0431\u043e <a href=\"http:\/\/libvips.github.io\/libvips\/\" rel=\"noopener noreferrer nofollow\"><u>libvips<\/u><\/a>.<\/p>\n<p>\u0412 <code>Gemfile.lock<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f <code>image_processing<\/code>. \u041d\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 <a href=\"https:\/\/guides.rubyonrails.org\/active_storage_overview.html#requirements\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u0433\u0435\u043c\u0430 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u0432 <code>config\/application.rb<\/code> \u0441\u0442\u0440\u043e\u043a\u0443 (<a href=\"https:\/\/github.com\/rails\/rails\/blob\/aa2052ec4ceb64682828154e8669ac0327c678db\/activestorage\/app\/models\/active_storage\/variant.rb#L14\" rel=\"noopener noreferrer nofollow\">\u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 ActiveStorage::Variant<\/a>:<\/p>\n<pre><code class=\"ruby\">config.active_storage.variant_processor = :mini_magick<\/code><\/pre>\n<h4>2. app\/javascript\/application.js<\/h4>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 JavaScript \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/www.npmjs.com\/package\/trix\" rel=\"noopener noreferrer nofollow\"><u>trix<\/u><\/a> \u0438 <a href=\"https:\/\/www.npmjs.com\/package\/@rails\/actiontext\" rel=\"noopener noreferrer nofollow\"><u>@rails\/actiontext<\/u><\/a>.<\/p>\n<h4>3. config\/importmap.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 js-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043e\u0442\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 c \u044d\u0442\u0438\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u0422\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0441\u044f JavaScript \u043a\u043e\u0434 \u0434\u043b\u044f <code>Trix<\/code>. \u0412 <code>DevTools<\/code> \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 <code>Debugger<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435, \u0433\u0434\u0435<\/p>\n<p>  1 &#8212; imports,<\/p>\n<p>  2 &#8212; js &#8212; \u0444\u0430\u0439\u043b\u044b,<\/p>\n<p>  3 &#8212; Trix \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5a4\/fa4\/4c4\/5a4fa44c42dc92cdc7eebf043096e048.png\" alt=\"\" title=\"\" width=\"1436\" height=\"893\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a4\/fa4\/4c4\/5a4fa44c42dc92cdc7eebf043096e048.png\"\/><\/figure>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 css\/js \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 (\u0441\u043c. <a href=\"https:\/\/guides.rubyonrails.org\/asset_pipeline.html\" rel=\"noopener noreferrer nofollow\">The Asset Pipeline<\/a>:<\/p>\n<pre><code class=\"ruby\">bin\/rails assets:precompile<\/code><\/pre>\n<h4>4. test\/fixtures\/action_text\/rich_texts.yml &#8212; \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<h4>5. app\/assets\/stylesheets\/actiontext.css &#8212; \u0441\u0442\u0438\u043b\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"css\">.trix-content .attachment-gallery > action-text-attachment, .trix-content .attachment-gallery > .attachment {   flex: 1 0 33%;   padding: 0 0.5em;   max-width: 33%; }  .trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment, .trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment, .trix-content .attachment-gallery.attachment-gallery--4 > .attachment {   flex-basis: 50%;   max-width: 50%; }  .trix-content action-text-attachment .attachment {   padding: 0 !important;   max-width: 100% !important; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0439 css \u0444\u0430\u0439\u043b, \u043d\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 html \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>action-text-attachment<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\" rel=\"noopener noreferrer nofollow\">html-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/a>, \u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f html-\u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>&lt;action-text-attachment><\/code> \u0441 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CustomElementRegistry\" rel=\"noopener noreferrer nofollow\"><u>CustomElementRegistry<\/u><\/a>.<\/p>\n<h4>6. db\/migrate\/20230210142600_create_active_storage_tables.active_storage.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043b\u0430\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>active_storage_<\/code>:<\/p>\n<p>* <code>active_storage_blobs<\/code><\/p>\n<p>* <code>active_storage_attachments<\/code><\/p>\n<p>* <code>active_storage_variant_records<\/code><\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/edgeguides.rubyonrails.org\/active_storage_overview.html\" rel=\"noopener noreferrer nofollow\">Active Storage Overview<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 20230210142600_create_active_storage_tables.active_storage.rb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"ruby\"># This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables &lt; ActiveRecord::Migration[5.2]   def change     # Use Active Record's configured type for primary and foreign keys     primary_key_type, foreign_key_type = primary_and_foreign_key_types      create_table :active_storage_blobs, id: primary_key_type do |t|       t.string   :key,          null: false       t.string   :filename,     null: false       t.string   :content_type       t.text     :metadata       t.string   :service_name, null: false       t.bigint   :byte_size,    null: false       t.string   :checksum        if connection.supports_datetime_with_precision?         t.datetime :created_at, precision: 6, null: false       else         t.datetime :created_at, null: false       end        t.index [ :key ], unique: true     end      create_table :active_storage_attachments, id: primary_key_type do |t|       t.string     :name,     null: false       t.references :record,   null: false, polymorphic: true, index: false, type: foreign_key_type       t.references :blob,     null: false, type: foreign_key_type        if connection.supports_datetime_with_precision?         t.datetime :created_at, precision: 6, null: false       else         t.datetime :created_at, null: false       end        t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true       t.foreign_key :active_storage_blobs, column: :blob_id     end      create_table :active_storage_variant_records, id: primary_key_type do |t|       t.belongs_to :blob, null: false, index: false, type: foreign_key_type       t.string :variation_digest, null: false        t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true       t.foreign_key :active_storage_blobs, column: :blob_id     end   end    private     def primary_and_foreign_key_types       config = Rails.configuration.generators       setting = config.options[config.orm][:primary_key_type]       primary_key_type = setting || :primary_key       foreign_key_type = setting || :bigint       [primary_key_type, foreign_key_type]     end end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442\u0441\u044f \u0432 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>active_storage_attachments<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p><code>name<\/code> \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c,<\/p>\n<\/li>\n<li>\n<p><code>record_type,<\/code><\/p>\n<\/li>\n<li>\n<p><code>record_id<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>bigint<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 <code>record_type<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 <code>polymorphic: true<\/code> (\u0441\u043c. <a href=\"https:\/\/guides.rubyonrails.org\/active_record_migrations.html#references\" rel=\"noopener noreferrer nofollow\">Active Record Migrations References<\/a>),<\/p>\n<\/li>\n<li>\n<p><code>blob_id<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>bigint<\/code>, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c <code>id<\/code> \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>active_storage_blobs<\/code>, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043f\u043e <code>blob_id,<\/code><\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 <code>record_type<\/code>, <code>record_id<\/code>, <code>name<\/code>, <code>blob_id<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h4>7. db\/migrate\/20230210142601_create_action_text_tables.action_text.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043b\u0430\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>action_text_<\/code> (\u0442\u0430\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430):<\/p>\n<ul>\n<li>\n<p><code>action_text_rich_texts<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432 \u043f\u043e\u043b\u0435 <code>body<\/code> \u0438 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 html. \u0412\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0438 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 20230210142601_create_action_text_tables.action_text.rb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"ruby\"># This migration comes from action_text (originally 20180528164100) class CreateActionTextTables &lt; ActiveRecord::Migration[6.0]   def change     # Use Active Record's configured type for primary and foreign keys     primary_key_type, foreign_key_type = primary_and_foreign_key_types      create_table :action_text_rich_texts, id: primary_key_type do |t|       t.string     :name, null: false       t.text       :body, size: :long       t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type        t.timestamps        t.index [ :record_type, :record_id, :name ], name: \"index_action_text_rich_texts_uniqueness\", unique: true     end   end    private     def primary_and_foreign_key_types       config = Rails.configuration.generators       setting = config.options[config.orm][:primary_key_type]       primary_key_type = setting || :primary_key       foreign_key_type = setting || :bigint       [primary_key_type, foreign_key_type]     end end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>bin\/rails db:migrate<\/code> \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>8. app\/views\/layouts\/action_text\/contents\/_content.html.erb<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 _content.html.erb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;div class=\"trix-content\">   &lt;%= yield %> &lt;\/div><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>body<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 html, \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>action_text_rich_texts<\/code>.<\/p>\n<h4>9. app\/views\/active_storage\/blobs\/_blob.html.erb<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 _blob.html.erb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;figure class=\"attachment attachment--&lt;%= blob.representable? ? \"preview\" : \"file\" %> attachment--&lt;%= blob.filename.extension %>\">   &lt;% if blob.representable? %>     &lt;%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>   &lt;% end %>    &lt;figcaption class=\"attachment__caption\">     &lt;% if caption = blob.try(:caption) %>       &lt;%= caption %>     &lt;% else %>       &lt;span class=\"attachment__name\">&lt;%= blob.filename %>&lt;\/span>       &lt;span class=\"attachment__size\">&lt;%= number_to_human_size blob.byte_size %>&lt;\/span>     &lt;% end %>   &lt;\/figcaption> &lt;\/figure>  &lt;!--\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0430\u0439\u043b.--> &lt;% if !blob.image? %>   &lt;div>     &lt;span class=\"attachment__download\">&lt;%= link_to blob.filename, rails_blob_path(blob) %>&lt;\/span>     &lt;span class=\"attachment__size\">(&lt;%= number_to_human_size blob.byte_size %>)&lt;\/span>   &lt;\/div> &lt;% end %><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 DevTools \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0441 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bca\/d50\/860\/bcad50860d6a0e3e1587c425a8b85c57.png\" width=\"1907\" height=\"873\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bca\/d50\/860\/bcad50860d6a0e3e1587c425a8b85c57.png\"\/><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u043c html \u043a\u0443\u0441\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>active_storage_blobs<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0cd\/759\/5cc\/0cd7595cc4326a8b0e192ed8027378b5.png\" width=\"1832\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0cd\/759\/5cc\/0cd7595cc4326a8b0e192ed8027378b5.png\"\/><\/figure>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>action_text_rich_texts<\/code>.<\/p>\n<p>\u0412 <code>_blob.html.erb<\/code> \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p><a class=\"anchor\" name=\"how-model-links-to-active-text\" id=\"how-model-links-to-active-text\"><\/a><\/p>\n<h3>\u041a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c ActionText \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 action_text_rich_texts?<\/h3>\n<p>\u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u044f \u043f\u0438\u0448\u0443 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044e <a href=\"https:\/\/api.rubyonrails.org\/classes\/ActionText\/Attribute.html#method-i-has_rich_text\" rel=\"noopener noreferrer nofollow\"><u>has_rich_text<\/u><\/a>.<\/p>\n<pre><code class=\"ruby\">class Note &lt; ApplicationRecord   has_rich_text :body end<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0432 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e <code>body<\/code>:<\/p>\n<pre><code class=\"ruby\">class NotesController &lt; ApplicationController   def create     @note = Note.create!(note_params)      redirect_to note_path @note   end      private    def note_params = params.require(:note).permit(:title, :body) end<\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 <code>has_rich_text<\/code> \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/actiontext\/lib\/action_text\/attribute.rb#L37\" rel=\"noopener noreferrer nofollow\">\u043c\u0435\u0442\u043e\u0434<\/a> \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f <code>ActionText::Attribute<\/code>.<\/p>\n<p><a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/actiontext\/lib\/action_text\/attribute.rb#L37\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<\/a> \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f <code>rails<\/code> \u0447\u0438\u0442\u0430\u044e \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043c\u043e\u0434\u0435\u043b\u0438: \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 <code>body?<\/code>, \u0441\u0435\u0442\u0442\u0435\u0440 \u0438 \u0433\u0435\u0442\u0442\u0435\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/guides.rubyonrails.org\/association_basics.html#the-has-one-association\" rel=\"noopener noreferrer nofollow\">\u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044f<\/a> <code>rich_text_body<\/code> \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 <code>ActionText::RichText<\/code>, \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u043e\u043b\u044f <code>name<\/code>. <code>as: :record<\/code> &#8212; \u043f\u0440\u0438\u0437\u043d\u0430\u043a <a href=\"https:\/\/guides.rubyonrails.org\/association_basics.html#polymorphic-associations\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438<\/a>, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u043d\u043e \u0431\u044b\u043b\u043e \u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>action_text_rich_texts<\/code>. \u042d\u0442\u0430 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044f \u0438\u043d\u0432\u0435\u0440\u0441\u043d\u0430\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 <a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/actiontext\/app\/models\/action_text\/rich_text.rb#L8\" rel=\"noopener noreferrer nofollow\">ActionText::RichText<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>record<\/code>.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0448\u0435\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"ruby\">> note = Note.find(1) =begin &lt;Note:0x00007efee9a06ce0                                                                  id: 1,                                                                                    title: \"\u0420\u044b\u0431\u0430\u0422\u0435\u043a\u0441\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u043c\",                                                  hidden: false,                                                                            created_at: Sun, 19 Feb 2023 11:24:47.510481000 UTC +00:00,                               updated_at: Sun, 19 Feb 2023 11:24:47.613920000 UTC +00:00>  =end > > note.body =begin &lt;ActionText::RichText:0x00007efee9848688  id: 1,                                   name: \"body\",                         body: #&lt;ActionText::Content \"&lt;div class=\\\"trix-conte...\">,  record_type: \"Note\",                     record_id: 1,                            created_at: Sun, 19 Feb 2023 11:24:47.564128000 UTC +00:00,  updated_at: Sun, 19 Feb 2023 11:24:47.583755000 UTC +00:00> =end > > action_text_item = ActionText::RichText.find(1) =begin &lt;ActionText::RichText:0x00007efee9848688  id: 1,                                   name: \"body\",                         body: #&lt;ActionText::Content \"&lt;div class=\\\"trix-conte...\">,  record_type: \"Note\",                     record_id: 1,                            created_at: Sun, 19 Feb 2023 11:24:47.564128000 UTC +00:00,  updated_at: Sun, 19 Feb 2023 11:24:47.583755000 UTC +00:00> =end > > action_text_item.record =begin &lt;Note:0x00007efee9a06ce0                                                                  id: 1,                                                                                    title: \"\u0420\u044b\u0431\u0430\u0422\u0435\u043a\u0441\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u043c\",                                                  hidden: false,                                                                            created_at: Sun, 19 Feb 2023 11:24:47.510481000 UTC +00:00,                               updated_at: Sun, 19 Feb 2023 11:24:47.613920000 UTC +00:00> =end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418\u0442\u043e\u0433\u043e, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e <code>note.body<\/code> \u0438 \u043f\u043e\u0438\u0441\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>ActionText::RichText<\/code> \u043f\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c\u0443 <code>id<\/code> \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044c, \u0447\u0442\u043e \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043f\u0446\u0438\u044f <code>inverse_of<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e.<\/p>\n<p><a class=\"anchor\" name=\"how-active_storage_blobs-save-files\" id=\"how-active_storage_blobs-save-files\"><\/a><\/p>\n<h3>\u041a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b\/\u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0432 \u0437\u0430\u043f\u0438\u0441\u044f\u0445?<\/h3>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435, \u043d\u0430\u0436\u0438\u043c\u0430\u044f \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0441\u043a\u0440\u0435\u043f\u043a\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043e\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0438\u0441\u0443\u043d\u043a\u0430, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u0433\u0434\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0441\u0435\u0440\u0432\u0435\u0440, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 <code>POST \"\/rails\/active_storage\/direct_uploads\"<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/activestorage\/app\/controllers\/active_storage\/direct_uploads_controller.rb#L7\" rel=\"noopener noreferrer nofollow\">ActiveStorage::DirectUploadsController#create<\/a> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"json\">{   \"blob\": {     \"filename\": \"cat.jpg\",     \"content_type\": \"image\/jpeg\",     \"byte_size\": 107329,     \"checksum\": \"JuFhMdR3g4JjS73owAJLQA==\"   },   \"direct_upload\": {     \"blob\": {       \"filename\": \"cat.jpg\",       \"content_type\": \"image\/jpeg\",       \"byte_size\": 107329,       \"checksum\": \"JuFhMdR3g4JjS73owAJLQA==\"       }     }   }<\/code><\/pre>\n<p>\u0412 <code>ActiveStorage::DirectUploadsController#create<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/activestorage\/app\/models\/active_storage\/blob.rb#L103\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435<\/a> \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"ruby\">TRANSACTION (0.4ms)  BEGIN ActiveStorage::Blob Create (0.7ms)  INSERT INTO \"active_storage_blobs\" (\"key\", \"filename\", \"content_type\", \"metadata\", \"service_name\", \"byte_size\", \"checksum\", \"created_at\") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING \"id\"  [[\"key\", \"ikydgdsgyrgupbqqh0wdqtgs75y4\"], [\"filename\", \"cat.jpg\"], [\"content_type\", \"image\/jpeg\"], [\"metadata\", nil], [\"service_name\", \"minio\"], [\"byte_size\", 107329], [\"checksum\", \"JuFhMdR3g4JjS73owAJLQA==\"], [\"created_at\", \"2023-02-23 16:35:59.956614\"]] TRANSACTION (0.8ms)  COMMIT S3 Storage (45.7ms) Generated URL for file at key: ikydgdsgyrgupbqqh0wdqtgs75y4 (http:\/\/localhost:9000\/main\/ikydgdsgyrgupbqqh0wdqtgs75y4?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=minioadmin%2F20230223%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20230223T163600Z&amp;X-Amz-Expires=300&amp;X-Amz-SignedHeaders=content-length%3Bcontent-md5%3Bcontent-type%3Bhost&amp;X-Amz-Signature=696eaa54d2f921beaa552de1263fdb8b548708d12ebbdd3df6e97d7077dedeff)<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0438\u0441\u043a\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043a <code>local<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>config\/storage.yml<\/code> \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>service<\/code> \u0431\u0443\u0434\u0435\u0442 <code>Disk<\/code>. \u0418\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>key<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u043f\u0430\u043f\u043a\u0430 \u0438 \u0432\u0441\u0435 \u043f\u0430\u043f\u043a\u0438 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 <code>storage<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d02\/9f0\/068\/d029f00680ca459c1f41ed88d6256073.png\" width=\"2053\" height=\"617\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d02\/9f0\/068\/d029f00680ca459c1f41ed88d6256073.png\"\/><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0435\u043d\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0441\u0442, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0444\u0430\u0439\u043b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u0435\u043b\u0435 <code>rich_text<\/code>. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <code>active_storage_attachments<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 <code>action_text_rich_texts<\/code> \u0438 <code>active_storage_blobs<\/code>. <\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>active_storage_attachments<\/code>:<\/p>\n<ul>\n<li>\n<p>\u0432 \u043f\u043e\u043b\u0435 <code>record_id<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f <code>id<\/code> \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>action_text_rich_texts<\/code>, <\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u043e\u043b\u0435 <code>record_type<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f\/\u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>action_text_rich_texts<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u043e\u043b\u0435 <code>blob_id<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f <code>id<\/code> \u0444\u0430\u0439\u043b\u0430\/\u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>active_storage_blobs<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u043e\u043b\u0435 <code>name<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u0444\u0430\u0439\u043b\u0430\/\u0440\u0438\u0441\u0443\u043d\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"end\" id=\"end\"><\/a><\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e<\/h3>\n<p>\u041e\u0445\u0432\u0430\u0442\u0438\u043b\u0430:<\/p>\n<ul>\n<li>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>bin\/rails action_text:install<\/code><\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u044d\u0442\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0447\u0435\u0440\u0435\u0437 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044e <code>has_rich_text<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 <code>A\u0441tionText<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u043e\u043d\u0447\u0443. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435. \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0431\u043e\u0440 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 <code>libvips<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>ImageMagick<\/code>. <a href=\"https:\/\/github.com\/libvips\/libvips\/wiki\/Speed-and-memory-use\" rel=\"noopener noreferrer nofollow\">\u041f\u0438\u0448\u0443\u0442<\/a>, \u0447\u0442\u043e <code>libvips<\/code> \u043d\u043e\u0432\u0435\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>C\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>active_storage_variant_records<\/code>. \u0412 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <a href=\"https:\/\/github.com\/rails\/rails\/blob\/e9cb3c7b2f63bac810efb46cf8902cadaadcbdcd\/actiontext\/app\/models\/action_text\/rich_text.rb#L15\" rel=\"noopener noreferrer nofollow\">has_many_attached :embeds<\/a> \u043a\u043b\u0430\u0441\u0441\u0430 <code>ActionText::RichText<\/code> \u044f \u043d\u0435 \u043d\u0430\u0448\u043b\u0430 <code>variant<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0423\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u044f \u0432\u0430\u043c \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/720462\/\"> https:\/\/habr.com\/ru\/post\/720462\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/p>\n<p><a href=\"#goal\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043b\u044c<\/a><br \/><a href=\"#generated\" rel=\"noopener noreferrer nofollow\">\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b<\/a><br \/><a href=\"#how-model-links-to-active-text\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c ActionText \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 action_text_rich_texts<\/a><br \/><a href=\"#how-active_storage_blobs-save-files\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b\/\u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0432 \u0437\u0430\u043f\u0438\u0441\u044f\u0445<\/a><br \/><a href=\"#end\" rel=\"noopener noreferrer nofollow\">\u0418\u0442\u043e\u0433\u043e<\/a><\/p>\n<p><a class=\"anchor\" name=\"goal\" id=\"goal\"><\/a><\/p>\n<h3>\u0426\u0435\u043b\u044c<\/h3>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 &#8212; \u0447\u0430\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0421\u0443\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 &#8212; \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0430\u0439\u0442.<\/p>\n<p>\u0412\u00a0<a href=\"https:\/\/rubyonrails.org\/\" rel=\"noopener noreferrer nofollow\">Ruby on Rails<\/a>\u00a0\u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<a href=\"https:\/\/api.rubyonrails.org\/classes\/ActionText.html\" rel=\"noopener noreferrer nofollow\">ActionText<\/a>\u00a0\u0441\u00a0<a href=\"https:\/\/guides.rubyonrails.org\/action_text_overview.html\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 Rails. \u041e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u00a0<a href=\"https:\/\/trix-editor.org\/\" rel=\"noopener noreferrer nofollow\">Trix<\/a>. \u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 JavaScript, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430) \u0438 \u0440\u0438\u0441\u0443\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043d\u0438\u0436\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Note<\/code>, \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 (show\/edit\/new.html.erb), \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p><a class=\"anchor\" name=\"generated\" id=\"generated\"><\/a><\/p>\n<h3>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>Action Text<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">bin\/rails action_text:install<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u041f\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0438 \u0443\u0437\u043d\u0430\u0435\u043c:<\/p>\n<h4>1. Gemfile, Gemfile.lock<\/h4>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0433\u0435\u043c <a href=\"https:\/\/github.com\/janko\/image_processing\" rel=\"noopener noreferrer nofollow\"><u>image_processing<\/u><\/a>. \u042d\u0442\u043e\u0442 \u043f\u0430\u043a\u0435\u0442 \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c (\u0441\u0436\u0438\u043c\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440) \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442. \u042d\u0442\u043e\u0442 \u0433\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438\u0431\u043e <a href=\"https:\/\/www.imagemagick.org\/\" rel=\"noopener noreferrer nofollow\">ImageMagick<\/a>\/<a href=\"https:\/\/www.imagemagick.org\/\" rel=\"noopener noreferrer nofollow\">GraphicsMagick<\/a>, \u043b\u0438\u0431\u043e <a href=\"http:\/\/libvips.github.io\/libvips\/\" rel=\"noopener noreferrer nofollow\"><u>libvips<\/u><\/a>.<\/p>\n<p>\u0412 <code>Gemfile.lock<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f <code>image_processing<\/code>. \u041d\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 <a href=\"https:\/\/guides.rubyonrails.org\/active_storage_overview.html#requirements\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u0433\u0435\u043c\u0430 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u0432 <code>config\/application.rb<\/code> \u0441\u0442\u0440\u043e\u043a\u0443 (<a href=\"https:\/\/github.com\/rails\/rails\/blob\/aa2052ec4ceb64682828154e8669ac0327c678db\/activestorage\/app\/models\/active_storage\/variant.rb#L14\" rel=\"noopener noreferrer nofollow\">\u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 ActiveStorage::Variant<\/a>:<\/p>\n<pre><code class=\"ruby\">config.active_storage.variant_processor = :mini_magick<\/code><\/pre>\n<h4>2. app\/javascript\/application.js<\/h4>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 JavaScript \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/www.npmjs.com\/package\/trix\" rel=\"noopener noreferrer nofollow\"><u>trix<\/u><\/a> \u0438 <a href=\"https:\/\/www.npmjs.com\/package\/@rails\/actiontext\" rel=\"noopener noreferrer nofollow\"><u>@rails\/actiontext<\/u><\/a>.<\/p>\n<h4>3. config\/importmap.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 js-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043e\u0442\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 c \u044d\u0442\u0438\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u0422\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0441\u044f JavaScript \u043a\u043e\u0434 \u0434\u043b\u044f <code>Trix<\/code>. \u0412 <code>DevTools<\/code> \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 <code>Debugger<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435, \u0433\u0434\u0435<\/p>\n<p>  1 &#8212; imports,<\/p>\n<p>  2 &#8212; js &#8212; \u0444\u0430\u0439\u043b\u044b,<\/p>\n<p>  3 &#8212; Trix \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 css\/js \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 (\u0441\u043c. <a href=\"https:\/\/guides.rubyonrails.org\/asset_pipeline.html\" rel=\"noopener noreferrer nofollow\">The Asset Pipeline<\/a>:<\/p>\n<pre><code class=\"ruby\">bin\/rails assets:precompile<\/code><\/pre>\n<h4>4. test\/fixtures\/action_text\/rich_texts.yml &#8212; \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<h4>5. app\/assets\/stylesheets\/actiontext.css &#8212; \u0441\u0442\u0438\u043b\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"css\">.trix-content .attachment-gallery > action-text-attachment, .trix-content .attachment-gallery > .attachment {   flex: 1 0 33%;   padding: 0 0.5em;   max-width: 33%; }  .trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment, .trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment, .trix-content .attachment-gallery.attachment-gallery--4 > .attachment {   flex-basis: 50%;   max-width: 50%; }  .trix-content action-text-attachment .attachment {   padding: 0 !important;   max-width: 100% !important; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0439 css \u0444\u0430\u0439\u043b, \u043d\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 html \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>action-text-attachment<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\" rel=\"noopener noreferrer nofollow\">html-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/a>, \u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f html-\u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>&lt;action-text-attachment><\/code> \u0441 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CustomElementRegistry\" rel=\"noopener noreferrer nofollow\"><u>CustomElementRegistry<\/u><\/a>.<\/p>\n<h4>6. db\/migrate\/20230210142600_create_active_storage_tables.active_storage.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043b\u0430\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>active_storage_<\/code>:<\/p>\n<p>* <code>active_storage_blobs<\/code><\/p>\n<p>* <code>active_storage_attachments<\/code><\/p>\n<p>* <code>active_storage_variant_records<\/code><\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/edgeguides.rubyonrails.org\/active_storage_overview.html\" rel=\"noopener noreferrer nofollow\">Active Storage Overview<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 20230210142600_create_active_storage_tables.active_storage.rb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"ruby\"># This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables &lt; ActiveRecord::Migration[5.2]   def change     # Use Active Record's configured type for primary and foreign keys     primary_key_type, foreign_key_type = primary_and_foreign_key_types      create_table :active_storage_blobs, id: primary_key_type do |t|       t.string   :key,          null: false       t.string   :filename,     null: false       t.string   :content_type       t.text     :metadata       t.string   :service_name, null: false       t.bigint   :byte_size,    null: false       t.string   :checksum        if connection.supports_datetime_with_precision?         t.datetime :created_at, precision: 6, null: false       else         t.datetime :created_at, null: false       end        t.index [ :key ], unique: true     end      create_table :active_storage_attachments, id: primary_key_type do |t|       t.string     :name,     null: false       t.references :record,   null: false, polymorphic: true, index: false, type: foreign_key_type       t.references :blob,     null: false, type: foreign_key_type        if connection.supports_datetime_with_precision?         t.datetime :created_at, precision: 6, null: false       else         t.datetime :created_at, null: false       end        t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true       t.foreign_key :active_storage_blobs, column: :blob_id     end      create_table :active_storage_variant_records, id: primary_key_type do |t|       t.belongs_to :blob, null: false, index: false, type: foreign_key_type       t.string :variation_digest, null: false        t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true       t.foreign_key :active_storage_blobs, column: :blob_id     end   end    private     def primary_and_foreign_key_types       config = Rails.configuration.generators       setting = config.options[config.orm][:primary_key_type]       primary_key_type = setting || :primary_key       foreign_key_type = setting || :bigint       [primary_key_type, foreign_key_type]     end end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0443\u0442\u0441\u044f \u0432 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>active_storage_attachments<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044f:<\/p>\n<ul>\n<li>\n<p><code>name<\/code> \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c,<\/p>\n<\/li>\n<li>\n<p><code>record_type,<\/code><\/p>\n<\/li>\n<li>\n<p><code>record_id<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>bigint<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 <code>record_type<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 <code>polymorphic: true<\/code> (\u0441\u043c. <a href=\"https:\/\/guides.rubyonrails.org\/active_record_migrations.html#references\" rel=\"noopener noreferrer nofollow\">Active Record Migrations References<\/a>),<\/p>\n<\/li>\n<li>\n<p><code>blob_id<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>bigint<\/code>, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c <code>id<\/code> \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>active_storage_blobs<\/code>, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043f\u043e <code>blob_id,<\/code><\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 <code>record_type<\/code>, <code>record_id<\/code>, <code>name<\/code>, <code>blob_id<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h4>7. db\/migrate\/20230210142601_create_action_text_tables.action_text.rb<\/h4>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043b\u0430\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>action_text_<\/code> (\u0442\u0430\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430):<\/p>\n<ul>\n<li>\n<p><code>action_text_rich_texts<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432 \u043f\u043e\u043b\u0435 <code>body<\/code> \u0438 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 html. \u0412\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0438 \u0438 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 20230210142601_create_action_text_tables.action_text.rb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"ruby\"># This migration comes from action_text (originally 20180528164100) class CreateActionTextTables &lt; ActiveRecord::Migration[6.0]   def change     # Use Active Record's configured type for primary and foreign keys     primary_key_type, foreign_key_type = primary_and_foreign_key_types      create_table :action_text_rich_texts, id: primary_key_type do |t|       t.string     :name, null: false       t.text       :body, size: :long       t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type        t.timestamps        t.index [ :record_type, :record_id, :name ], name: \"index_action_text_rich_texts_uniqueness\", unique: true     end   end    private     def primary_and_foreign_key_types       config = Rails.configuration.generators       setting = config.options[config.orm][:primary_key_type]       primary_key_type = setting || :primary_key       foreign_key_type = setting || :bigint       [primary_key_type, foreign_key_type]     end end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>bin\/rails db:migrate<\/code> \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>8. app\/views\/layouts\/action_text\/contents\/_content.html.erb<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 _content.html.erb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;div class=\"trix-content\">   &lt;%= yield %> &lt;\/div><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>body<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 html, \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>action_text_rich_texts<\/code>.<\/p>\n<h4>9. app\/views\/active_storage\/blobs\/_blob.html.erb<\/h4>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 _blob.html.erb<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;figure class=\"attachment attachment--&lt;%= blob.representable? ? \"preview\" : \"file\" %> attachment--&lt;%= blob.filename.extension %>\">   &lt;% if blob.representable? %>     &lt;%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>   &lt;% end %>    &lt;figcaption class=\"attachment__caption\">     &lt;% if caption = blob.try(:caption) %>       &lt;%= caption %>     &lt;% else %>       &lt;span class=\"attachment__name\">&lt;%= blob.filename %>&lt;\/span>       &lt;span class=\"attachment__size\">&lt;%= number_to_human_size blob.byte_size %>&lt;\/span>     &lt;% end %>   &lt;\/figcaption> &lt;\/figure>  &lt;!--\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0430\u0439\u043b.--> &lt;% if !blob.image? %>   &lt;div>     &lt;span class=\"attachment__download\">&lt;%= link_to blob.filename, rails_blob_path(blob) %>&lt;\/span>     &lt;span class=\"attachment__size\">(&lt;%= number_to_human_size blob.byte_size %>)&lt;\/span>   &lt;\/div> &lt;% end %><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 DevTools \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0441 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u043c html \u043a\u0443\u0441\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>active_storage_blobs<\/code>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 Trix-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>action_text_rich_texts<\/code>.<\/p>\n<p>\u0412 <code>_blob.html.erb<\/code> \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p><a class=\"anchor\" name=\"how-model-links-to-active-text\" id=\"how-model-links-to-active-text\"><\/a><\/p>\n<h3>\u041a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c ActionText \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 action_text_rich_texts?<\/h3>\n<p>\u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u044f \u043f\u0438\u0448\u0443 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044e <a href=\"https:\/\/api.rubyonrails.org\/classes\/ActionText\/Attribute.html#method-i-has_rich_text\" rel=\"noopener noreferrer nofollow\"><u>has_rich_text<\/u><\/a>.<\/p>\n<pre><code class=\"ruby\">class Note &lt; ApplicationRecord   has_rich_text :body end<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0432 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e <code>body<\/code>:<\/p>\n<pre><code class=\"ruby\">class NotesController &lt; ApplicationController   def create     @note = Note.create!(note_params)     <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346271","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346271"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346271\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}