{"id":980,"date":"2022-09-14T11:38:54","date_gmt":"2023-04-01T07:33:55","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/"},"modified":"2025-08-01T04:01:11","modified_gmt":"2025-07-31T19:01:11","slug":"%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/","title":{"rendered":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d"},"content":{"rendered":"<p>\u7b46\u8005\u306f\u3001Write for Donations\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e00\u74b0\u3068\u3057\u3066\u3001\u5bc4\u4ed8\u91d1\u3092\u53d7\u3051\u53d6\u308b\u56e3\u4f53\u3068\u3057\u3066Electronic Frontier Foundation\u3092\u9078\u3073\u307e\u3057\u305f\u3002<\/p>\n<h3>\u30a4\u30f3\u30c8\u30ed\u30c0\u30af\u30b7\u30e7\u30f3<\/h3>\n<p>Ruby on Rails\u306f\u4eba\u6c17\u306e\u3042\u308b\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002GitHub\u3001Basecamp\u3001SoundCloud\u3001Airbnb\u3001Twitch\u306a\u3069\u3001\u73fe\u5728\u30a6\u30a7\u30d6\u4e0a\u3067\u5b58\u5728\u3059\u308b\u591a\u304f\u306e\u4eba\u6c17\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u7d4c\u9a13\u306b\u91cd\u70b9\u3092\u7f6e\u304d\u3001\u305d\u308c\u3092\u53d6\u308a\u5dfb\u304f\u60c5\u71b1\u7684\u306a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306b\u3088\u3063\u3066\u3001Ruby on Rails\u306f\u73fe\u4ee3\u306e\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u30fb\u7dad\u6301\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30c4\u30fc\u30eb\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>React\u306f\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u308bJavaScript\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002Facebook\u306e\u652f\u63f4\u3092\u53d7\u3051\u3066\u304a\u308a\u3001\u73fe\u5728\u306e\u30a6\u30a7\u30d6\u4e0a\u3067\u6700\u3082\u4eba\u6c17\u306e\u3042\u308b\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e00\u3064\u3067\u3059\u3002React\u306f\u3001\u4eee\u60f3DOM\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3001\u72b6\u614b\u7ba1\u7406\u306a\u3069\u306e\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u3066\u304a\u308a\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u3088\u308a\u7d44\u7e54\u5316\u3055\u308c\u305f\u52b9\u7387\u7684\u306a\u3082\u306e\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>Web\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30b3\u30fc\u30c9\u3068\u306f\u5225\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u79fb\u884c\u3057\u3066\u3044\u307e\u3059\u3002Rails\u306e\u30a8\u30ec\u30ac\u30f3\u30b9\u3068React\u306e\u52b9\u7387\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u6700\u65b0\u306e\u30c8\u30ec\u30f3\u30c9\u306b\u57fa\u3065\u3044\u305f\u30d1\u30ef\u30d5\u30eb\u3067\u73fe\u4ee3\u7684\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Rails\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u306f\u306a\u304f\u3001React\u3092\u4f7f\u7528\u3057\u3066Rails\u30d3\u30e5\u30fc\u5185\u304b\u3089\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u3067\u3001\u6700\u65b0\u306eJavaScript\u3068\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u306e\u9032\u6b69\u3092\u6d3b\u7528\u3057\u306a\u304c\u3089\u3001Ruby on Rails\u306e\u8868\u73fe\u529b\u3092\u751f\u304b\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Ruby on Rails\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3001\u304a\u6c17\u306b\u5165\u308a\u306e\u30ec\u30b7\u30d4\u3092\u4fdd\u5b58\u3057\u3001\u305d\u308c\u3092React\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3067\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u7d42\u4e86\u3059\u308b\u3068\u3001Bootstrap\u3067\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3055\u308c\u305fReact\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3001\u8868\u793a\u3001\u524a\u9664\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/6-0.png\" alt=\"Screencapture of the completed recipe app home page\" \/><\/div>\n<h2>\u524d\u63d0\u6761\u4ef6<\/h2>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u5f93\u3046\u305f\u3081\u306b\u306f\u3001\u6b21\u306e\u3082\u306e\u304c\u5fc5\u8981\u3067\u3059\uff1a<\/p>\n<ul class=\"post-ul\">\n<li>Node.js and npm installed on your development machine. This tutorial uses Node.js version 16.14.0 and npm version 8.3.1. Node.js is a JavaScript run-time environment that allows you to run your code outside the browser. It comes with a pre-installed Package Manager called npm, which lets you install and update packages. To install these on Ubuntu 20.04 or macOS, follow the \u201cInstalling Using a PPA\u201d section of How To Install Node.js on Ubuntu 20.04 or the steps in How to Install Node.js and Create a Local Development Environment on macOS.<\/li>\n<li>The Yarn package manager installed on your development machine, which will allow you to download the React framework. This tutorial was tested on version 1.22.10; to install this dependency, follow the official Yarn installation guide.<\/li>\n<li>Ruby on Rails installed. To get this, follow our guide on How to Install Ruby on Rails with rbenv on Ubuntu 20.04. If you would like to develop this application on macOS, you can use How To Install Ruby on Rails with rbenv on macOS. This tutorial was tested on version 3.1.2 of Ruby and version 7.0.4 of Rails, so make sure to specify these versions during the installation process.<\/li>\n<\/ul>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>\u6ce8\u610f\uff1aRails\u30d0\u30fc\u30b8\u30e7\u30f37\u306f\u4e92\u63db\u6027\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u3082\u3057Rails\u30d0\u30fc\u30b8\u30e7\u30f35\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001Ubuntu 18.04\u3067Ruby on Rails v5\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306bReact\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/div>\n<\/div>\n<ul class=\"post-ul\">\n<li>PostgreSQL installed, as described in Steps 1 and 2 How To Use PostgreSQL with Your Ruby on Rails Application on Ubuntu 20.04 or How To Use PostgreSQL with Your Ruby on Rails Application on macOS. To follow this tutorial, you can use PostgreSQL version 12 or higher. If you want to develop this application on a different distribution of Linux or another OS, see the official PostgreSQL downloads page. For more information on how to use PostgreSQL, see How To Install and Use PostgreSQL.<\/li>\n<\/ul>\n<h2>\u30b9\u30c6\u30c3\u30d71 &#8211; \u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210<\/h2>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u4e0a\u306b\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002\u307e\u305a\u6700\u521d\u306b\u3001React\u3068\u9023\u643a\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>Rails\u306f\u3001\u73fe\u4ee3\u306e\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u3044\u304f\u3064\u304b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30b3\u30de\u30f3\u30c9\u306e\u5b8c\u5168\u306a\u30ea\u30b9\u30c8\u3068\u305d\u308c\u3089\u306e\u5f79\u5272\u3092\u78ba\u8a8d\u3059\u308b\u306b\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails <span class=\"token parameter variable\">-h<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u5305\u62ec\u7684\u306a\u30ea\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u30ea\u30b9\u30c8\u306b\u306f\u3001\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u300cnew\u300d\u30b3\u30de\u30f3\u30c9\u3082\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u3001\u65b0\u3057\u3044\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails new <mark>rails_react_recipe<\/mark> <span class=\"token parameter variable\">-d<\/span> postgresql <span class=\"token parameter variable\">-j<\/span> esbuild <span class=\"token parameter variable\">-c<\/span> bootstrap <span class=\"token parameter variable\">-T<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u524d\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u304crails_react_recipe\u3067\u3042\u308b\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3001\u5fc5\u8981\u306aRuby\u304a\u3088\u3073JavaScript\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Webpack\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u65b0\u3057\u3044\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30b3\u30de\u30f3\u30c9\u306b\u95a2\u9023\u3059\u308b\u30d5\u30e9\u30b0\u306b\u306f\u4ee5\u4e0b\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>The -d flag specifies the preferred database engine, which in this case is PostgreSQL.<\/li>\n<li>The -j flag specifies the application\u2019s JavaScript approach. Rails offers a few different ways to handle Javascript code in Rails applications. The esbuild option passed to the -j flag instructs Rails to preconfigure esbuild as the preferred JavaScript bundler.<\/li>\n<li>The -c flag specifies the application\u2019s CSS processor. Bootstrap is the preferred option in this case.<\/li>\n<li>The -T flag instructs Rails to skip the generation of test files since you won\u2019t be writing tests for this tutorial. This command is also suggested if you want to use a Ruby testing tool different from the one Rails provides.<\/li>\n<\/ul>\n<p>\u30b3\u30de\u30f3\u30c9\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u30a2\u30d7\u30ea\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308brails_react_recipe\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token builtin class-name\">cd<\/span> <mark>rails_react_recipe<\/mark><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5185\u5bb9\u3092\u30ea\u30b9\u30c8\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">ls<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u5185\u5bb9\u3092\u5370\u5237\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Gemfile README.md bin db node_modules storage yarn.lock Gemfile.lock Rakefile config lib package.json tmp Procfile.dev app config.ru log public vendor<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306f\u3001\u81ea\u52d5\u751f\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3068\u30d5\u30a9\u30eb\u30c0\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306fRails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u69cb\u9020\u3092\u69cb\u6210\u3059\u308b\u3082\u306e\u3067\u3042\u308a\u3001React\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f9d\u5b58\u95a2\u4fc2\u304c\u542b\u307e\u308c\u308bpackage.json\u30d5\u30a1\u30a4\u30eb\u3082\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u6210\u529f\u88cf\u306b\u4f5c\u6210\u3057\u305f\u306e\u3067\u3001\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d72 \u2014 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a<\/h2>\n<p>\u65b0\u3057\u3044Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u3001\u307e\u305a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u65b0\u3057\u304f\u4f5c\u6210\u3057\u305fRails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092PostgreSQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3066\u3001\u30ec\u30b7\u30d4\u30c7\u30fc\u30bf\u3092\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u4fdd\u5b58\u304a\u3088\u3073\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>config\/database.yml\u306b\u3042\u308bdatabase.yml\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u958b\u767a\u74b0\u5883\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u306a\u3069\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a73\u7d30\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002Rails\u306f\u74b0\u5883\u540d\u306e\u5f8c\u306b\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2(_)\u3092\u4ed8\u3051\u3066\u3001\u3055\u307e\u3056\u307e\u306a\u958b\u767a\u74b0\u5883\u306b\u5bfe\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u5b9a\u5024\u3092\u4f7f\u7528\u3057\u307e\u3059\u304c\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a\u5024\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>\u6ce8\u610f\uff1a\u3053\u306e\u6642\u70b9\u3067\u3001config\/database.yml\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3067\u3001\u3069\u306ePostgreSQL\u306e\u30ed\u30fc\u30eb\u3092Rails\u304c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u304b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u524d\u63d0\u6761\u4ef6\u306e\u4e2d\u3067\u3001How To Use PostgreSQL with Your Ruby on Rails Application\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u4fdd\u8b77\u3055\u308c\u305f\u30ed\u30fc\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u307e\u3060\u30e6\u30fc\u30b6\u30fc\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u540c\u3058\u524d\u63d0\u6761\u4ef6\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u30b9\u30c6\u30c3\u30d74 &#8211; \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a\u3068\u4f5c\u6210\u306e\u624b\u9806\u306b\u5f93\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/div>\n<\/div>\n<p>Rails\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4f5c\u6210\u3001\u524a\u9664\u3001\u30ea\u30bb\u30c3\u30c8\u306a\u3069\u3001\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u3092\u5bb9\u6613\u306b\u3059\u308b\u591a\u304f\u306e\u30b3\u30de\u30f3\u30c9\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u305f\u3081\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails db:create<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u958b\u767a\u304a\u3088\u3073\u30c6\u30b9\u30c8\u7528\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u306e\u51fa\u529b\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Created database &#8216;rails_react_recipe_development&#8217; Created database &#8216;rails_react_recipe_test&#8217;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3066\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">bin\/dev<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>Rails\u306f\u3001Foreman gem\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308bProcfile.dev\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3059\u308b\u4ee3\u66ff\u306ebin\/dev\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u6d88\u3048\u3001\u305d\u306e\u4ee3\u308f\u308a\u306b\u4ee5\u4e0b\u306e\u51fa\u529b\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>started with pid 70099 started with pid 70100 started with pid 70101 yarn run <mark>v1.22.10<\/mark> yarn run <mark>v1.22.10<\/mark> $ esbuild app\/javascript\/*.* &#8211;bundle &#8211;sourcemap &#8211;outdir=app\/assets\/builds &#8211;public-path=assets &#8211;watch $ sass .\/app\/assets\/stylesheets\/application.bootstrap.scss:.\/app\/assets\/builds\/application.css &#8211;no-source-map &#8211;load-path=node_modules &#8211;watch =&gt; Booting Puma =&gt; Rails <mark>7.0.4<\/mark> application starting in development =&gt; Run `bin\/rails server &#8211;help` for more startup options [watch] build finished, watching for changes&#8230; Puma starting in single mode&#8230; * Puma version: <mark>5.6.5<\/mark> (ruby 3.1.2-p20) (&#8220;Birdie&#8217;s Version&#8221;) * Min threads: 5 * Max threads: 5 * Environment: development * PID: 70099 * Listening on http:\/\/127.0.0.1:3000 * Listening on http:\/\/[::1]:3000 Use Ctrl-C to stop Sass is watching for changes. Press Ctrl-C to stop.<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3042\u306a\u305f\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u958b\u304d\u3001http:\/\/localhost:3000 \u306b\u79fb\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002Rails\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a6\u30a7\u30eb\u30ab\u30e0\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u3067\u3059\u3002\u3053\u308c\u306f\u3001\u3042\u306a\u305f\u304cRails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u6b63\u3057\u304f\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3067\u304d\u3066\u3044\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/43-0.png\" alt=\"Screencapture of the Rails welcome page\" \/><\/div>\n<p>\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u3092\u505c\u6b62\u3059\u308b\u306b\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u304c\u52d5\u4f5c\u3057\u3066\u3044\u308b\u30bf\u30fc\u30df\u30ca\u30eb\u3067CTRL+C\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002Puma\u304b\u3089\u5225\u308c\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>^C SIGINT received, starting shutdown &#8211; Gracefully stopping, waiting for requests to finish === puma shutdown: 2019-07-31 14:21:24 -0400 === &#8211; Goodbye! Exiting sending SIGTERM to all processes terminated by SIGINT terminated by SIGINT exited with code 0<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u305d\u306e\u5f8c\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u518d\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u3001\u6599\u7406\u306e\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u6b63\u5e38\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001React\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u7d44\u307f\u7acb\u3066\u308b\u305f\u3081\u306b\u5fc5\u8981\u306aJavaScript\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d73\uff1a\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u98df\u4e8b\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306b\u5fc5\u8981\u306aJavaScript\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u4ee5\u4e0b\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>React for building user interfaces.<\/li>\n<li>React DOM to enable React to interact with the browser DOM.<\/li>\n<li>React Router for handling navigation in a React application.<\/li>\n<\/ul>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001Yarn\u30d1\u30c3\u30b1\u30fc\u30b8\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3067\u3053\u308c\u3089\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">yarn<\/span> <span class=\"token function\">add<\/span> react react-dom react-router-dom<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u6307\u5b9a\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u3092Yarn\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u305d\u308c\u3089\u3092package.json\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308bpackage.json\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> package.json<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3001\u4f9d\u5b58\u95a2\u4fc2\u30ad\u30fc\u306e\u4e0b\u306b\u30ea\u30b9\u30c8\u3055\u308c\u307e\u3059\u3002<\/p>\n<div>\u300c~\/rails_react_recipe\/package.json\u300d\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u300c~\/rails_react_recipe\/package.json\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>{\r\n  \"name\": \"app\",\r\n  \"private\": \"true\",\r\n  \"dependencies\": {\r\n    \"@hotwired\/stimulus\": \"^3.1.0\",\r\n    \"@hotwired\/turbo-rails\": \"^7.1.3\",\r\n    \"@popperjs\/core\": \"^2.11.6\",\r\n    \"bootstrap\": \"^5.2.1\",\r\n    \"bootstrap-icons\": \"^1.9.1\",\r\n    \"esbuild\": \"^0.15.7\",\r\n    <mark>\"react\": \"^18.2.0\",<\/mark>\r\n    <mark>\"react-dom\": \"^18.2.0\",<\/mark>\r\n    <mark>\"react-router-dom\": \"^6.3.0\",<\/mark>\r\n    \"sass\": \"^1.54.9\"\r\n  },\r\n  \"scripts\": {\r\n    \"build\": \"esbuild app\/javascript\/*.* --bundle --sourcemap --outdir=app\/assets\/builds --public-path=assets\",\r\n    \"build:css\": \"sass .\/app\/assets\/stylesheets\/application.bootstrap.scss:.\/app\/assets\/builds\/application.css --no-source-map --load-path=node_modules\"\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>CTRL+X\u3092\u62bc\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u4f9d\u5b58\u95a2\u4fc2\u3092\u3044\u304f\u3064\u304b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f\u3002\u6b21\u306b\u3001\u98df\u4e8b\u30ec\u30b7\u30d4\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d74 \u2014 \u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306e\u8a2d\u5b9a<\/h2>\n<p>\u5fc5\u8981\u306a\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5f8c\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u521d\u3081\u3066\u8a2a\u308c\u305f\u3068\u304d\u306b\u3001\u30e9\u30f3\u30c7\u30a3\u30f3\u30b0\u30da\u30fc\u30b8\u3068\u3057\u3066\u6a5f\u80fd\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>Rails\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5bfe\u3057\u3066Model-View-Controller\u306e\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u30d1\u30bf\u30fc\u30f3\u3092\u63a1\u7528\u3057\u3066\u3044\u307e\u3059\u3002MVC\u30d1\u30bf\u30fc\u30f3\u3067\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u76ee\u7684\u306f\u7279\u5b9a\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u3001\u9069\u5207\u306a\u30e2\u30c7\u30eb\u3084\u30d3\u30e5\u30fc\u306b\u6e21\u3059\u3053\u3068\u3067\u3059\u3002\u73fe\u5728\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30eb\u30fc\u30c8URL\u304c\u30d6\u30e9\u30a6\u30b6\u3067\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3068Rails\u306e\u30a6\u30a7\u30eb\u30ab\u30e0\u30da\u30fc\u30b8\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306b\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306e\u305f\u3081\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3068\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30eb\u30fc\u30c8\u306b\u30de\u30c3\u30c1\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>Rails\u306b\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u751f\u6210\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u751f\u6210\u6a5f\u80fd\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u540d\u3068\u5bfe\u5fdc\u3059\u308b\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001Rails\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3068\u547c\u3076\u3053\u3068\u306b\u3057\u307e\u3059\u3002\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u6301\u3064\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails g controller <mark>Homepage<\/mark> index<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>\u6ce8\u610f\uff1a<br \/>\nLinux\u3067\u306f\u3001\u30a8\u30e9\u30fcFATAL: Listen\u30a8\u30e9\u30fc:\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5909\u66f4\u3092\u76e3\u8996\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u306f\u3001\u30de\u30b7\u30f3\u304c\u5909\u66f4\u3092\u76e3\u8996\u3067\u304d\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u6570\u306b\u95a2\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u5236\u9650\u306e\u7d50\u679c\u3067\u3042\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4fee\u6b63\u3057\u3066\u304f\u3060\u3055\u3044\uff1a<br \/>\necho fs.inotify.max_user_watches=524288 | sudo tee -a \/etc\/sysctl.conf &amp;&amp; sudo sysctl -p<\/div>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001Listen\u3067\u76e3\u8996\u3067\u304d\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u6570\u3092\u6c38\u4e45\u306b524288\u306b\u5897\u3084\u3057\u307e\u3059\u3002\u540c\u3058\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066524288\u3092\u5e0c\u671b\u306e\u6570\u5024\u306b\u7f6e\u304d\u63db\u3048\u308b\u3053\u3068\u3067\u3001\u518d\u5ea6\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<\/div>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u6b21\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>A homepage_controller.rb file for receiving all homepage-related requests. This file contains the index action you specified in the command.<\/li>\n<li>A homepage_helper.rb file for adding helper methods related to the Homepage controller.<\/li>\n<li>An index.html.erb file as the view page for rendering anything related to the homepage.<\/li>\n<\/ul>\n<p>Rails\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u4f5c\u6210\u3055\u308c\u308b\u65b0\u3057\u3044\u30da\u30fc\u30b8\u4ee5\u5916\u306b\u3082\u3001Rails\u306fconfig\/routes.rb\u306b\u3042\u308b\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u7528\u306eGET\u30eb\u30fc\u30c8\u304c\u8ffd\u52a0\u3055\u308c\u3001\u3053\u308c\u3092\u30eb\u30fc\u30c8\u30eb\u30fc\u30c8\u3068\u3057\u3066\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>Rails\u306e\u30eb\u30fc\u30c8\u30eb\u30fc\u30c8\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30eb\u30fc\u30c8URL\u3092\u8a2a\u308c\u305f\u3068\u304d\u306b\u8868\u793a\u3055\u308c\u308b\u5185\u5bb9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u306f\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3067\u3059\u3002\u304a\u6c17\u306b\u5165\u308a\u306e\u30a8\u30c7\u30a3\u30bf\u3067config\/routes.rb\u306b\u3042\u308b\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> config\/routes.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001&#8217;homepage\/index&#8217;\u3092&#8217;homepage#index&#8217;\u306b\u7f6e\u304d\u63db\u3048\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4e00\u81f4\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>~\/rails_react_recipe\/config\/routes.rb\u306e\u5185\u5bb9\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068:<\/p>\n<p>\u300c~\/rails_react_recipe\/config\/routes.rb\u300d\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>Rails.application.routes.draw do\r\n  <mark>root 'homepage#index'<\/mark>\r\n  # For details on the DSL available within this file, see http:\/\/guides.rubyonrails.org\/routing.html\r\nend\r\n<\/code><\/pre>\n<p>\u3053\u306e\u4fee\u6b63\u306f\u3001Rails\u306b\u5bfe\u3057\u3066\u30eb\u30fc\u30c8\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092Homepage\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306eindex\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3059\u308b\u3088\u3046\u6307\u793a\u3057\u3001\u305d\u306e\u7d50\u679c\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u306fapp\/views\/homepage\/index.html.erb\u306b\u3042\u308bindex.html.erb\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u308b\u3002<\/p>\n<p>\u3053\u306e\u52d5\u4f5c\u304c\u6b63\u5e38\u306b\u884c\u308f\u308c\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">bin\/dev<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u3044\u305f\u308a\u66f4\u65b0\u3057\u305f\u308a\u3059\u308b\u5834\u5408\u3001\u65b0\u3057\u3044\u521d\u671f\u753b\u9762\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u8aad\u307f\u8fbc\u307e\u308c\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/80-0.webp\" alt=\"The \" \/><\/div>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u5f8c\u3001\u30b5\u30fc\u30d0\u30fc\u3092\u505c\u6b62\u3059\u308b\u305f\u3081\u306bCTRL+C\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6b21\u306b\u3001~\/rails_react_recipe\/app\/views\/homepage\/index.html.erb \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/views\/homepage\/index.html.erb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u30b3\u30fc\u30c9\u3092\u524a\u9664\u3057\u3001\u7a7a\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u306b\u3088\u308a\u3001index.html.erb\u306e\u5185\u5bb9\u304c\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306eReact\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306b\u5e72\u6e09\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3092\u8a2d\u5b9a\u3057\u305f\u3089\u3001React\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u69cb\u6210\u3059\u308b\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u79fb\u52d5\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d75 &#8211; \u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u306eReact\u306e\u8a2d\u5b9a\u3092Rails\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u3057\u3066\u884c\u3044\u307e\u3059\u3002<\/h2>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001Rails\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306bReact\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u3053\u306e\u65b0\u3057\u3044\u8a2d\u5b9a\u306b\u3088\u308a\u3001React\u3092\u4f7f\u3063\u3066\u3088\u308a\u9b45\u529b\u7684\u306a\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u751f\u6210\u3059\u308b\u969b\u306b\u6307\u5b9a\u3055\u308c\u305fesbuild\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u52a9\u3051\u3092\u501f\u308a\u3066\u3001JavaScript\u304cRails\u3068\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u9023\u643a\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u307b\u3068\u3093\u3069\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u304c\u3059\u3067\u306b\u5b8c\u4e86\u3057\u3066\u3044\u307e\u3059\u3002\u6b8b\u308b\u4f5c\u696d\u306f\u3001React\u30a2\u30d7\u30ea\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u3092esbuild\u306eJavaScript\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u306b\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u3092\u884c\u3046\u305f\u3081\u306b\u3001app\/javascript\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bcomponents\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">mkdir<\/span> ~\/rails_react_recipe\/app\/javascript\/components<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306f\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u3001React\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u306e\u4ed6\u306eReact\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u307e\u305f\u3001React\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3078\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u3082\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001app\/javascript\/application.js\u3068\u3044\u3046\u5834\u6240\u306b\u3042\u308bapplication.js\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/application.js<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u306b\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u4ee5\u4e0b\u306f\u3001\u30cd\u30a4\u30c6\u30a3\u30d6\u306a\u65e5\u672c\u8a9e\u3067\u306e\u30d1\u30e9\u30d5\u30ec\u30fc\u30ba\u4f8b\u3067\u3059\uff1a\u300c~\/rails_react_recipe\/app\/javascript\/application.js\u300d<\/div>\n<pre class=\"post-pre\"><code>\/\/ Entry point for the build script in your package.json\r\nimport \"@hotwired\/turbo-rails\"\r\nimport \".\/controllers\"\r\nimport * as bootstrap from \"bootstrap\"\r\n<mark>import \".\/components\"<\/mark>\r\n<\/code><\/pre>\n<p>application.js\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u52a0\u3055\u308c\u308b\u30b3\u30fc\u30c9\u884c\u306f\u3001entry index.jsx\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30fc\u30c9\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001esbuild\u3067\u30d0\u30f3\u30c9\u30eb\u3059\u308b\u305f\u3081\u306b\u5229\u7528\u53ef\u80fd\u306b\u3057\u307e\u3059\u3002Rails\u30a2\u30d7\u30ea\u306eJavaScript\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u306b\/components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u30a4\u30f3\u30dd\u30fc\u30c8\u3055\u308c\u308b\u3053\u3068\u3067\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u7528\u306eReact\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306b\u306f\u30c6\u30ad\u30b9\u30c8\u3068\u30ec\u30b7\u30d4\u3092\u3059\u3079\u3066\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30dc\u30bf\u30f3\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/p>\n<p>\u4fdd\u5b58\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bHome.jsx\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/components\/Home.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u65e5\u672c\u8a9e\u3067\u8ff0\u3079\u3066\u304f\u3060\u3055\u3044\uff08\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u4e00\u3064\u306e\u307f\u5fc5\u8981\u3067\u3059\uff09\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/Home.jsx<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { Link } from \"react-router-dom\";\r\n\r\nexport default () =&gt; (\r\n  &lt;div className=\"vw-100 vh-100 primary-color d-flex align-items-center justify-content-center\"&gt;\r\n    &lt;div className=\"jumbotron jumbotron-fluid bg-transparent\"&gt;\r\n      &lt;div className=\"container secondary-color\"&gt;\r\n        &lt;h1 className=\"display-4\"&gt;Food Recipes&lt;\/h1&gt;\r\n        &lt;p className=\"lead\"&gt;\r\n          A curated list of recipes for the best homemade meal and delicacies.\r\n        &lt;\/p&gt;\r\n        &lt;hr className=\"my-4\" \/&gt;\r\n        &lt;Link\r\n          to=\"\/recipes\"\r\n          className=\"btn btn-lg custom-button\"\r\n          role=\"button\"\r\n        &gt;\r\n          View Recipes\r\n        &lt;\/Link&gt;\r\n      &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/div&gt;\r\n);\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001React\u3068React Router\u304b\u3089Link\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002Link\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u3001\u30da\u30fc\u30b8\u9593\u3092\u79fb\u52d5\u3059\u308b\u305f\u3081\u306e\u30cf\u30a4\u30d1\u30fc\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u6b21\u306b\u3001Bootstrap\u306e\u30af\u30e9\u30b9\u3067\u30b9\u30bf\u30a4\u30eb\u5316\u3055\u308c\u305f\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306e\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u8a00\u8a9e\u3092\u542b\u3080\u6a5f\u80fd\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30db\u30fc\u30e0\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u8a2d\u5b9a\u3055\u308c\u305f\u3089\u3001React Router\u3092\u4f7f\u7528\u3057\u3066\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002app\/javascript\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306broutes\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">mkdir<\/span> ~\/rails_react_recipe\/app\/javascript\/routes<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u30eb\u30fc\u30c8\u3068\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u6307\u5b9a\u3055\u308c\u305f\u30eb\u30fc\u30c8\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u305f\u3073\u306b\u3001\u5bfe\u5fdc\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u30d6\u30e9\u30a6\u30b6\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3001index.jsx\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u305d\u308c\u306b\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { BrowserRouter as Router, Routes, Route } from \"react-router-dom\";\r\nimport Home from \"..\/components\/Home\";\r\n\r\nexport default (\r\n  &lt;Router&gt;\r\n    &lt;Routes&gt;\r\n      &lt;Route path=\"\/\" element={&lt;Home \/&gt;} \/&gt;\r\n    &lt;\/Routes&gt;\r\n  &lt;\/Router&gt;\r\n);\r\n<\/code><\/pre>\n<p>\u3053\u306eindex.jsx\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001\u6b21\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\uff1aReact\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306eReact\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u304a\u3088\u3073React Router\u304b\u3089\u306eBrowserRouter\u3001Routes\u3001\u304a\u3088\u3073Route\u30e2\u30b8\u30e5\u30fc\u30eb\u3002\u3053\u308c\u3089\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u5171\u306b\u30eb\u30fc\u30c8\u304b\u3089\u5225\u306e\u30eb\u30fc\u30c8\u306b\u79fb\u52d5\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u30eb\u30fc\u30c8(\/)\u3068\u4e00\u81f4\u3059\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u3042\u308b\u5834\u5408\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u308bHome\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u8ffd\u52a0\u306e\u30da\u30fc\u30b8\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u30eb\u30fc\u30c8\u3092\u5ba3\u8a00\u3057\u3001\u305d\u306e\u30da\u30fc\u30b8\u306e\u305f\u3081\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u4e00\u81f4\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>React Router\u3092\u4f7f\u7528\u3057\u3066\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002React\u304c\u5229\u7528\u53ef\u80fd\u306a\u30eb\u30fc\u30c8\u3092\u8a8d\u8b58\u3057\u3001\u305d\u308c\u3089\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u3067\u30eb\u30fc\u30c8\u304c\u5229\u7528\u53ef\u80fd\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u3001React\u304c\u30a8\u30f3\u30c8\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5185\u3067\u30eb\u30fc\u30c8\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<\/p>\n<p>\u300capp\/javascript\/components\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u300cApp.jsx\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/components\/App.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>App.jsx\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/App.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/App.jsx<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport Routes from \"..\/routes\";\r\n\r\nexport default props =&gt; &lt;&gt;{Routes}&lt;\/&gt;;\r\n<\/code><\/pre>\n<p>App.jsx \u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001React\u3068\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u5185\u3067\u30eb\u30fc\u30c8\u3092\u63cf\u753b\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u3067\u63cf\u753b\u3055\u308c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u3068\u304d\u306b\u5e38\u306b\u30eb\u30fc\u30c8\u304c\u5229\u7528\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3001\u9589\u3058\u308b\u3002<\/p>\n<p>App.jsx\u3092\u8a2d\u5b9a\u3057\u305f\u306e\u3067\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u3067\u305d\u308c\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bindex.jsx\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/components\/index.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>index.js\u30d5\u30a1\u30a4\u30eb\u306b\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/index.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001<\/p>\n<p>\u300c~\/rails_react_recipe\/app\/javascript\/components\/index.jsx\u30d5\u30a1\u30a4\u30eb\u300d<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { createRoot } from \"react-dom\/client\";\r\nimport App from \".\/App\";\r\n\r\ndocument.addEventListener(\"turbo:load\", () =&gt; {\r\n  const root = createRoot(\r\n    document.body.appendChild(document.createElement(\"div\"))\r\n  );\r\n  root.render(&lt;App \/&gt;);\r\n});\r\n<\/code><\/pre>\n<p>import\u306e\u884c\u3067\u306f\u3001React\u30e9\u30a4\u30d6\u30e9\u30ea\u3068ReactDOM\u304b\u3089createRoot\u95a2\u6570\u3001\u304a\u3088\u3073App\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002ReactDOM\u306ecreateRoot\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30eb\u30fc\u30c8\u8981\u7d20\u3092\u30da\u30fc\u30b8\u306b\u8ffd\u52a0\u3055\u308c\u305fdiv\u8981\u7d20\u3068\u3057\u3066\u4f5c\u6210\u3057\u3001\u305d\u306e\u4e2d\u306bApp\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u3068\u3001React\u306fApp\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5185\u5bb9\u3092\u30da\u30fc\u30b8\u4e0a\u306ediv\u8981\u7d20\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306b\u3044\u304f\u3064\u304b\u306eCSS\u30b9\u30bf\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>~\/rails_react_recipe\/app\/assets\/stylesheets\/application.bootstrap.scss\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306eapplication.bootstrap.scss\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/assets\/stylesheets\/application.bootstrap.scss<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u6b21\u306b\u3001application.bootstrap.scss\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u6b21\u306e\u30b3\u30fc\u30c9\u3067\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u300c~\/rails_react_recipe\/app\/assets\/stylesheets\/application.bootstrap.scss\u300d\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n\u300c~\/rails_react_recipe\/app\/assets\/stylesheets\/application.bootstrap.scss\u300d<\/div>\n<pre class=\"post-pre\"><code><span class=\"token atrule\"><span class=\"token rule\">@import<\/span> <span class=\"token string\">'bootstrap\/scss\/bootstrap'<\/span><span class=\"token punctuation\">;<\/span><\/span>\r\n<span class=\"token atrule\"><span class=\"token rule\">@import<\/span> <span class=\"token string\">'bootstrap-icons\/font\/bootstrap-icons'<\/span><span class=\"token punctuation\">;<\/span><\/span>\r\n\r\n<span class=\"token selector\"><span class=\"token class\">.bg_primary-color<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">background-color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#FFFFFF<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.primary-color<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">background-color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#FFFFFF<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.bg_secondary-color<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">background-color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#293241<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.secondary-color<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#293241<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.custom-button<\/span><span class=\"token class\">.btn<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">background-color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#293241<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">color<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token hexcode color\">#FFF<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">border<\/span><span class=\"token punctuation\">:<\/span> none<span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.hero<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">100<\/span><span class=\"token unit\">vw<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">50<\/span><span class=\"token unit\">vh<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.hero<\/span> img<\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">object-fit<\/span><span class=\"token punctuation\">:<\/span> cover<span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">object-position<\/span><span class=\"token punctuation\">:<\/span> top<span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">100<\/span><span class=\"token unit\">%<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">100<\/span><span class=\"token unit\">%<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token selector\"><span class=\"token class\">.overlay<\/span><\/span> <span class=\"token punctuation\">{<\/span>\r\n  <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">100<\/span><span class=\"token unit\">%<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">100<\/span><span class=\"token unit\">%<\/span><span class=\"token punctuation\">;<\/span>\r\n  <span class=\"token property\">opacity<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">0.4<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u306e\u901a\u308a\u3001\u65e5\u672c\u8a9e\u3067\u306e\u30d1\u30e9\u30d5\u30ec\u30fc\u30ba\u63d0\u4f9b\u3044\u305f\u3057\u307e\u3059\uff08\u4e00\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u307f\uff09\uff1a<br \/>\n\u30da\u30fc\u30b8\u306b\u30ab\u30b9\u30bf\u30e0\u8272\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002.hero\u30bb\u30af\u30b7\u30e7\u30f3\u306f\u3001\u5f8c\u3067\u8ffd\u52a0\u3059\u308b\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30d5\u30ed\u30f3\u30c8\u30da\u30fc\u30b8\u306b\u8868\u793a\u3055\u308c\u308b\u30d2\u30fc\u30ed\u30fc\u30a4\u30e1\u30fc\u30b8\u307e\u305f\u306f\u5927\u304d\u306a\u30d0\u30ca\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3055\u3089\u306b\u3001custom-button.btn\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5165\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u30dc\u30bf\u30f3\u306b\u30b9\u30bf\u30a4\u30eb\u3092\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306eCSS\u30b9\u30bf\u30a4\u30eb\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u72b6\u614b\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6b21\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">bin\/dev<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u305d\u306e\u5f8c\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u518d\u8aad\u307f\u8fbc\u307f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5168\u304f\u65b0\u3057\u3044\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/141-0.png\" alt=\"The homepage with its new styling\" \/><\/div>\n<p>\u300cCTRL+C\u3067\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u3092\u505c\u6b62\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/p>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001React\u3092\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3001\u8aad\u307f\u53d6\u308a\u3001\u66f4\u65b0\u3001\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30e2\u30c7\u30eb\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d76 &#8211; \u30ec\u30b7\u30d4\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u30e2\u30c7\u30eb\u306e\u4f5c\u6210<\/h2>\n<p>React\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u305f\u3081\u3001\u30ec\u30b7\u30d4\u306e\u30e2\u30c7\u30eb\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u30ec\u30b7\u30d4\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u542b\u3080\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30c6\u30fc\u30d6\u30eb\u3092\u8868\u3057\u307e\u3059\u3002\u4e00\u65b9\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u30ec\u30b7\u30d4\u306e\u4f5c\u6210\u3001\u8aad\u307f\u53d6\u308a\u3001\u66f4\u65b0\u3001\u524a\u9664\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u51e6\u7406\u3057\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u30ec\u30b7\u30d4\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u3068\u3001\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u3053\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u3001\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u306b\u6e21\u3057\u307e\u3059\u3002\u30e2\u30c7\u30eb\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306b\u30ec\u30b7\u30d4\u30c7\u30fc\u30bf\u3068\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u3053\u306e\u60c5\u5831\u304c\u30d6\u30e9\u30a6\u30b6\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001Rails\u304c\u63d0\u4f9b\u3059\u308bgenerate model subcommand\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30e2\u30c7\u30eb\u540d\u3068\u305d\u306e\u5217\u3068\u30c7\u30fc\u30bf\u578b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails generate model Recipe name:string ingredients:text instruction:text image:string<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u524d\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001Rails\u306bRecipe\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3088\u3046\u6307\u793a\u3057\u3001\u540d\u524d\u5217\uff08string\u578b\uff09\u3001\u6750\u6599\u3068\u624b\u9806\u306e\u5217\uff08text\u578b\uff09\u3001\u304a\u3088\u3073\u753b\u50cf\u5217\uff08string\u578b\uff09\u3092\u4f5c\u6210\u3059\u308b\u3082\u306e\u3067\u3059\u3002\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u30e2\u30c7\u30eb\u3092Recipe\u3068\u540d\u4ed8\u3051\u307e\u3057\u305f\u3002\u306a\u305c\u306a\u3089\u3001Rails\u306e\u30e2\u30c7\u30eb\u306f\u5358\u6570\u5f62\u306e\u540d\u524d\u3092\u4f7f\u7528\u3057\u3001\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30c6\u30fc\u30d6\u30eb\u306f\u8907\u6570\u5f62\u306e\u540d\u524d\u3092\u4f7f\u7528\u3059\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u30e2\u30c7\u30eb\u751f\u6210\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u306b\u3088\u308a\u30012\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u3001\u4ee5\u4e0b\u306e\u51fa\u529b\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>invoke active_record create db\/migrate\/<mark>20221017220817<\/mark>_create_recipes.rb create app\/models\/recipe.rb<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4f5c\u6210\u3055\u308c\u305f2\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059:<\/p>\n<ul class=\"post-ul\">\n<li>A recipe.rb file that holds all the model-related logic.<\/li>\n<li>A 20221017220817_create_recipes.rb file (the number at the beginning of the file may differ depending on the date when you run the command). This migration file contains the instruction for creating the database structure.<\/li>\n<\/ul>\n<p>\u6b21\u306b\u3001\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u308b\u306e\u306f\u6709\u52b9\u306a\u30c7\u30fc\u30bf\u306e\u307f\u3068\u306a\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u30e2\u30c7\u30eb\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u76ee\u6a19\u3092\u9054\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>app\/models\/recipe.rb\u306b\u3042\u308b\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/models\/recipe.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/models\/recipe.rb\u3092\u65e5\u672c\u8a9e\u3067\u5de7\u307f\u306b\u8a00\u3044\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/div>\n<pre class=\"post-pre\"><code>class Recipe &lt; ApplicationRecord\r\n  <mark>validates :name, presence: true<\/mark>\r\n  <mark>validates :ingredients, presence: true<\/mark>\r\n  <mark>validates :instruction, presence: true<\/mark>\r\nend\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u30e2\u30c7\u30eb\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\u540d\u524d\u3001\u6750\u6599\u3001\u624b\u9806\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5b58\u5728\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u4e09\u3064\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u306a\u3044\u5834\u5408\u3001\u30ec\u30b7\u30d4\u306f\u7121\u52b9\u3067\u3042\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u308b\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30ec\u30b7\u30d4\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001Rails\u3067\u306f\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u7684\u306b\u5909\u66f4\u3092\u52a0\u3048\u308b\u65b9\u6cd5\u3067\u3059\u3002\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u6b63\u5e38\u306b\u52d5\u4f5c\u3059\u308b\u3088\u3046\u300120221017220817_create_recipes.rb\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u66f4\u3092\u52a0\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306e\u30a8\u30c7\u30a3\u30bf\u3067\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/db\/migrate\/<mark>20221017220817<\/mark>_create_recipes.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u4e00\u81f4\u3059\u308b\u3088\u3046\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u7d20\u6750\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>db\/migrate\/20221017220817_create_recipes.rb\u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306a\u8868\u73fe\u306b\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u300cdb\/migrate\/20221017220817_create_recipes.rb\u300d<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>class CreateRecipes &lt; ActiveRecord::Migration[5.2]\r\n  def change\r\n    create_table :recipes do |t|\r\n      t.string :name<mark>, null: false<\/mark>\r\n      t.text :ingredients<mark>, null: false<\/mark>\r\n      t.text :instruction<mark>, null: false<\/mark>\r\n      t.string :image<mark>, default: 'https:\/\/raw.githubusercontent.com\/do-community\/react_rails_recipe\/master\/app\/assets\/images\/Sammy_Meal.jpg'<\/mark>\r\n\r\n      t.timestamps\r\n    end\r\n  end\r\nend\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001change\u30e1\u30bd\u30c3\u30c9\u3092\u6301\u3064Ruby\u30af\u30e9\u30b9\u3068\u3001recipes\u3068\u3044\u3046\u540d\u524d\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u305d\u306e\u5217\u3068\u30c7\u30fc\u30bf\u578b\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u3055\u3089\u306b\u3001name\u3001ingredients\u3001instruction\u306e\u5217\u306b\u306fnull: false\u3092\u8ffd\u52a0\u3057\u3066\u3001\u3053\u308c\u3089\u306e\u5217\u304c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5909\u66f4\u3059\u308b\u524d\u306b\u5024\u3092\u6301\u3064\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001image\u5217\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a4\u30e1\u30fc\u30b8URL\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u7570\u306a\u308b\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u5225\u306eURL\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u5909\u66f4\u3092\u884c\u3063\u305f\u5f8c\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u3067\u79fb\u884c\u3092\u5b9f\u884c\u3057\u3001\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3057\u305f\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails db:migrate<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u547d\u4ee4\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30de\u30a4\u30b0\u30ec\u30fc\u30c8\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u30b3\u30de\u30f3\u30c9\u304c\u6b63\u5e38\u306b\u5b9f\u884c\u3055\u308c\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>== <mark>20190407161357<\/mark> CreateRecipes: migrating ==================================== &#8212; create_table(:recipes) -&gt; 0.0140s == <mark>20190407161357<\/mark> CreateRecipes: migrated (0.0141s) ===========================<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30ec\u30b7\u30d4\u30e2\u30c7\u30eb\u3092\u7528\u610f\u3057\u305f\u3089\u3001\u6b21\u306b\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u3066\u3001\u30ec\u30b7\u30d4\u306e\u4f5c\u6210\u3001\u8aad\u307f\u53d6\u308a\u3001\u524a\u9664\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails generate controller api\/v1\/Recipes index create show destroy &#8211;skip-template-engine &#8211;no-helper<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3067\u306f\u3001api\/v1\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bRecipes\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306b\u306f\u3001index\u3001create\u3001show\u3001destroy\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059\u3002index\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u5168\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u3092\u62c5\u5f53\u3057\u3001create\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u5f79\u5272\u3092\u6301\u3061\u307e\u3059\u3002show\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u5358\u4e00\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3057\u3001destroy\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u306f\u30ec\u30b7\u30d4\u3092\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30ed\u30b8\u30c3\u30af\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3088\u308a\u8efd\u91cf\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u3044\u304f\u3064\u304b\u306e\u30d5\u30e9\u30b0\u3092\u6e21\u3059\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>&#8211;skip-template-engine, which instructs Rails to skip generating Rails view files since React handles your front-end needs.<\/li>\n<li>&#8211;no-helper, which instructs Rails to skip generating a helper file for your controller.<\/li>\n<\/ul>\n<p>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u300cRecipes\u300d\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u5185\u306e\u5404\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u5bfe\u5fdc\u3059\u308b\u30eb\u30fc\u30c8\u304c\u3001\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u3082\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3055\u308c\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>create app\/controllers\/api\/v1\/recipes_controller.rb route namespace :api do namespace :v1 do get &#8216;recipes\/index&#8217; get &#8216;recipes\/create&#8217; get &#8216;recipes\/show&#8217; get &#8216;recipes\/destroy&#8217; end end<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u308c\u3089\u306e\u30eb\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u3001config\/routes.rb\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3057\u307e\u3059\u3002\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u3067routes.rb\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/config\/routes.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u5909\u66f4\u307e\u305f\u306f\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/config\/routes.rb\u3092\u65e5\u672c\u8a9e\u3067\u66f8\u304d\u63db\u3048\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<\/div>\n<pre class=\"post-pre\"><code>Rails.application.routes.draw do\r\n  namespace :api do\r\n    namespace :v1 do\r\n      get 'recipes\/index'\r\n      <mark>post<\/mark> 'recipes\/create'\r\n      get <mark>'\/show\/:id', to:<\/mark> 'recipes#show'\r\n      <mark>delete '\/destroy\/:id', to: 'recipes#destroy'<\/mark>\r\n    end\r\n  end\r\n  root 'homepage#index'\r\n  <mark>get '\/*path' =&gt; 'homepage#index'<\/mark>\r\n  # Define your application routes per the DSL in https:\/\/guides.rubyonrails.org\/routing.html\r\n\r\n  # Defines the root path route (\"\/\")\r\n  # root \"articles#index\"\r\nend\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001\u30af\u30ea\u30a8\u30a4\u30c8\u3068\u30c7\u30b9\u30c8\u30ed\u30a4\u306e\u30eb\u30fc\u30c8\u306eHTTP\u52d5\u8a5e\u3092\u5909\u66f4\u3057\u3066\u3001\u30c7\u30fc\u30bf\u306e\u30dd\u30b9\u30c8\u3084\u524a\u9664\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30b7\u30e7\u30fc\u3084\u30c7\u30b9\u30c8\u30ed\u30a4\u30a2\u30af\u30b7\u30e7\u30f3\u7528\u306e\u30eb\u30fc\u30c8\u306b:id\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u3066\u3001\u8aad\u307f\u8fbc\u307f\u3084\u524a\u9664\u3057\u305f\u3044\u30ec\u30b7\u30d4\u306e\u8b58\u5225\u756a\u53f7\u3092:id\u3067\u4fdd\u6301\u3057\u307e\u3059\u3002<\/p>\n<p>\u65e2\u5b58\u306e\u30eb\u30fc\u30c8\u306b\u30de\u30c3\u30c1\u3057\u306a\u3044\u4ed6\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u3001get &#8216;\/*path&#8217; \u306e\u30ad\u30e3\u30c3\u30c1\u30aa\u30fc\u30eb\u30eb\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u3001\u30ec\u30b7\u30d4\u306e\u4f5c\u6210\u3001\u8aad\u307f\u53d6\u308a\u3001\u524a\u9664\u3068\u95a2\u4fc2\u306e\u306a\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002 (Fairu o hozon shite shuuryou shite kudasai.)<\/p>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u5229\u7528\u53ef\u80fd\u306a\u30eb\u30fc\u30c8\u306e\u30ea\u30b9\u30c8\u3092\u8a55\u4fa1\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails routes<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306eURI\u30d1\u30bf\u30fc\u30f3\u3001\u52d5\u8a5e\u3001\u305d\u3057\u3066\u4e00\u81f4\u3059\u308b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u307e\u305f\u306f\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u4e00\u89a7\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u4e00\u5ea6\u306b\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002Rails\u306fActiveRecord\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3001\u3053\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u95a2\u9023\u306e\u30bf\u30b9\u30af\u3092\u51e6\u7406\u3057\u307e\u3059\u3002ActiveRecord\u306f\u30af\u30e9\u30b9\u3092\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u63a5\u7d9a\u3057\u3001\u305d\u308c\u3089\u3092\u6271\u3046\u305f\u3081\u306e\u8c4a\u5bcc\u306aAPI\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u3001ActiveRecord\u3092\u4f7f\u7528\u3057\u3066\u30ec\u30b7\u30d4\u30c6\u30fc\u30d6\u30eb\u3092\u30af\u30a8\u30ea\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u306e\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001recipes_controller.rb\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb\u306e\u30d1\u30e9\u30d5\u30ec\u30fc\u30ba\u3092\u65e5\u672c\u8a9e\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002\u4e00\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3060\u3051\u3067\u69cb\u3044\u307e\u305b\u3093\u3002<\/div>\n<pre class=\"post-pre\"><code>class Api::V1::RecipesController &lt; ApplicationController\r\n  def index\r\n    <mark>recipe = Recipe.all.order(created_at: :desc)<\/mark>\r\n    <mark>render json: recipe<\/mark>\r\n  end\r\n\r\n  def create\r\n  end\r\n\r\n  def show\r\n  end\r\n\r\n  def destroy\r\n  end\r\nend\r\n<\/code><\/pre>\n<p>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001ActiveRecord\u306eall\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u306e\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002order\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u4f5c\u6210\u65e5\u306b\u57fa\u3065\u3044\u3066\u964d\u9806\u306b\u4e26\u3079\u3066\u3001\u6700\u65b0\u306e\u30ec\u30b7\u30d4\u304c\u5148\u306b\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001render\u3092\u4f7f\u7528\u3057\u3066\u30ec\u30b7\u30d4\u306e\u30ea\u30b9\u30c8\u3092JSON\u5f62\u5f0f\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u3068\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u5168\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u306e\u3068\u540c\u69d8\u306b\u3001\u63d0\u4f9b\u3055\u308c\u305f\u30ec\u30b7\u30d4\u306e\u8a73\u7d30\u3092\u691c\u8a3c\u3057\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306bActiveRecord\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u4ee5\u4e0b\u306e\u5f37\u8abf\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3092\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb \u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001<br \/>\n\u300c~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb\u300d<\/div>\n<pre class=\"post-pre\"><code>class Api::V1::RecipesController &lt; ApplicationController\r\n  def index\r\n    recipe = Recipe.all.order(created_at: :desc)\r\n    render json: recipe\r\n  end\r\n\r\n  def create\r\n    <mark>recipe = Recipe.create!(recipe_params)<\/mark>\r\n    <mark>if recipe<\/mark>\r\n      <mark>render json: recipe<\/mark>\r\n    <mark>else<\/mark>\r\n      <mark>render json: recipe.errors<\/mark>\r\n    <mark>end<\/mark>\r\n  end\r\n\r\n  def show\r\n  end\r\n\r\n  def destroy\r\n  end\r\n\r\n  <mark>private<\/mark>\r\n\r\n  <mark>def recipe_params<\/mark>\r\n    <mark>params.permit(:name, :image, :ingredients, :instruction)<\/mark>\r\n  <mark>end<\/mark>\r\nend\r\n<\/code><\/pre>\n<p>create\uff08\u4f5c\u6210\uff09\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001ActiveRecord\u306ecreate\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002create\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30e2\u30c7\u30eb\u306b\u4e00\u5ea6\u306b\u63d0\u4f9b\u3055\u308c\u308b\u3059\u3079\u3066\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u30ec\u30b3\u30fc\u30c9\u306e\u4f5c\u6210\u3092\u5bb9\u6613\u306b\u3057\u307e\u3059\u304c\u3001\u60aa\u610f\u306e\u3042\u308b\u4f7f\u7528\u306e\u53ef\u80fd\u6027\u3082\u958b\u3044\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u60aa\u610f\u306e\u3042\u308b\u4f7f\u7528\u3092\u9632\u3050\u305f\u3081\u306b\u306f\u3001Rails\u304c\u63d0\u4f9b\u3059\u308bstrong parameters\u6a5f\u80fd\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u8a31\u53ef\u3055\u308c\u3066\u3044\u306a\u3044\u9650\u308a\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u30b3\u30fc\u30c9\u5185\u3067\u306f\u3001create\u30e1\u30bd\u30c3\u30c9\u306brecipe_params\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u307e\u3059\u3002recipe_params\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u9593\u9055\u3063\u305f\u30b3\u30f3\u30c6\u30f3\u30c4\u3084\u60aa\u610f\u306e\u3042\u308b\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u5165\u3089\u306a\u3044\u3088\u3046\u306b\u3001\u8a31\u53ef\u3059\u308b\u305f\u3081\u306e\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u540d\u524d\u3001\u753b\u50cf\u3001\u6750\u6599\u3001\u624b\u9806\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092create\u30e1\u30bd\u30c3\u30c9\u306e\u6b63\u5f53\u306a\u4f7f\u7528\u306e\u305f\u3081\u306b\u8a31\u53ef\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306e\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u3001\u73fe\u5728\u30ec\u30b7\u30d4\u3092\u8aad\u307f\u53d6\u308a\u3001\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6b8b\u308a\u306f\u5358\u4e00\u306e\u30ec\u30b7\u30d4\u3092\u8aad\u307f\u53d6\u308a\u3001\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30ed\u30b8\u30c3\u30af\u3067\u3059\u3002\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3067\u30ec\u30b7\u30d4\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001<br \/>\n\u300c~\/rails_react_recipe\/app\/controllers\/api\/v1\/recipes_controller.rb\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>class Api::V1::RecipesController &lt; ApplicationController\r\n  <mark>before_action :set_recipe, only: %i[show destroy]<\/mark>\r\n\r\n  def index\r\n    recipe = Recipe.all.order(created_at: :desc)\r\n    render json: recipe\r\n  end\r\n\r\n  def create\r\n    recipe = Recipe.create!(recipe_params)\r\n    if recipe\r\n      render json: recipe\r\n    else\r\n      render json: recipe.errors\r\n    end\r\n  end\r\n\r\n  def show\r\n    <mark>render json: @recipe<\/mark>\r\n  end\r\n\r\n  def destroy\r\n    <mark>@recipe&amp;.destroy<\/mark>\r\n    <mark>render json: { message: 'Recipe deleted!' }<\/mark>\r\n  end\r\n\r\n  private\r\n\r\n  def recipe_params\r\n    params.permit(:name, :image, :ingredients, :instruction)\r\n  end\r\n\r\n  <mark>def set_recipe<\/mark>\r\n    <mark>@recipe = Recipe.find(params[:id])<\/mark>\r\n  <mark>end<\/mark>\r\nend\r\n<\/code><\/pre>\n<p>\u65b0\u3057\u3044\u30b3\u30fc\u30c9\u306e\u4e2d\u3067\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408\u306b\u306e\u307fbefore_action\u3067\u547c\u3073\u51fa\u3055\u308c\u308bprivate\u306aset_recipe\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002set_recipe\u30e1\u30bd\u30c3\u30c9\u306fActiveRecord\u306efind\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001params\u3067\u63d0\u4f9b\u3055\u308c\u305fid\u3068\u4e00\u81f4\u3059\u308b\u30ec\u30b7\u30d4\u3092\u691c\u7d22\u3057\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570@recipe\u306b\u5272\u308a\u5f53\u3066\u307e\u3059\u3002show\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001set_recipe\u30e1\u30bd\u30c3\u30c9\u3067\u8a2d\u5b9a\u3055\u308c\u305f@recipe\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092JSON\u30ec\u30b9\u30dd\u30f3\u30b9\u3068\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u524a\u9664\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Ruby\u306e\u5b89\u5168\u306a\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u6f14\u7b97\u5b50&amp;.\u3092\u4f7f\u7528\u3057\u3066\u3001\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u969b\u306bnil\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u985e\u4f3c\u306e\u64cd\u4f5c\u3092\u884c\u3044\u307e\u3057\u305f\u3002\u3053\u306e\u8ffd\u52a0\u306b\u3088\u308a\u3001\u30ec\u30b7\u30d4\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306b\u306e\u307f\u524a\u9664\u3057\u3001\u5fdc\u7b54\u3068\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u5909\u66f4\u3092recipes_controller.rb\u306b\u884c\u3063\u305f\u5f8c\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u30ec\u30b7\u30d4\u7528\u306e\u30e2\u30c7\u30eb\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3067\u30ec\u30b7\u30d4\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8a18\u8ff0\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d77 \u30fc \u30ec\u30b7\u30d4\u306e\u95b2\u89a7<\/h2>\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u65e2\u5b58\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30da\u30fc\u30b8\u3068\u3001\u500b\u3005\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u5225\u306e\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u521d\u306b\u3001\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u524d\u306b\u3001\u73fe\u5728\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u7a7a\u306e\u305f\u3081\u3001\u4f5c\u696d\u3059\u308b\u305f\u3081\u306e\u30ec\u30b7\u30d4\u304c\u5fc5\u8981\u3067\u3059\u3002Rails\u306b\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b7\u30fc\u30c9\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7de8\u96c6\u7528\u306bseeds.rb\u3068\u3044\u3046\u30b7\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/db\/seeds.rb<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u30b7\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306e\u6700\u521d\u306e\u5185\u5bb9\u3092\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u4ee5\u4e0b\u306f\u65e5\u672c\u8a9e\u3067\u306e\u30d1\u30e9\u30d5\u30ec\u30fc\u30ba\u306e\u63d0\u6848\u3067\u3059\uff1a<br \/>\n~\/rails_react_recipe\/db\/seeds.rb \u2192 \u300c~\/rails_react_recipe\/db\/seeds.rb\u300d<\/div>\n<pre class=\"post-pre\"><code>9.times do |i|\r\n  Recipe.create(\r\n    name: \"Recipe #{i + 1}\",\r\n    ingredients: '227g tub clotted cream, 25g butter, 1 tsp cornflour,100g parmesan, grated nutmeg, 250g fresh fettuccine or tagliatelle, snipped chives or chopped parsley to serve (optional)',\r\n    instruction: 'In a medium saucepan, stir the clotted cream, butter, and cornflour over a low-ish heat and bring to a low simmer. Turn off the heat and keep warm.'\r\n  )\r\nend\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u30eb\u30fc\u30d7\u3092\u4f7f\u7528\u3057\u3066Rails\u306b9\u3064\u306e\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3057\u3001\u540d\u524d\u3001\u6750\u6599\u3001\u624b\u9806\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30c7\u30fc\u30bf\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u6295\u5165\u3059\u308b\u305f\u3081\u306b\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">rails db:seed<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b9\u3064\u306e\u30ec\u30b7\u30d4\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u3067\u3001\u305d\u308c\u3089\u3092\u53d6\u5f97\u3057\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3067\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5168\u3066\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u3001RecipesController\u306eindex\u30a2\u30af\u30b7\u30e7\u30f3\u306bHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u3001\u5168\u3066\u306e\u30ec\u30b7\u30d4\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30ec\u30b7\u30d4\u306f\u3001\u30da\u30fc\u30b8\u4e0a\u306e\u30ab\u30fc\u30c9\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>app\/javascript\/components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bRecipes.jsx\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> ~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u305f\u3089\u3001\u6b21\u306e\u884c\u3092\u8ffd\u52a0\u3057\u3066React\u3001useState\u3001useEffect\u3001Link\u3001useNavigate\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\uff1a&#8221;~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx&#8221;<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n<\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u3001\u95a2\u6570\u578b\u306eReact\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3042\u308b\u300cRecipes\u300d\u3092\u4f5c\u6210\u3057\u3066\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059:<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/\u30ec\u30b7\u30d4.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\n<mark>const Recipes = () =&gt; {<\/mark>\r\n  <mark>const navigate = useNavigate();<\/mark>\r\n  <mark>const [recipes, setRecipes] = useState([]);<\/mark>\r\n<mark>};<\/mark>\r\n\r\n<mark>export default Recipes;<\/mark>\r\n<\/code><\/pre>\n<p>\u30ec\u30b7\u30d4\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5185\u3067\u306f\u3001React Router\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3API\u304cuseNavigate\u30d5\u30c3\u30af\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002React\u306euseState\u30d5\u30c3\u30af\u306f\u3001\u30ec\u30b7\u30d4\u306e\u72b6\u614b\u3092\u521d\u671f\u5316\u3057\u3001\u305d\u308c\u306f\u7a7a\u306e\u914d\u5217\uff08[]\uff09\u3067\u3042\u308a\u3001\u30ec\u30b7\u30d4\u306e\u72b6\u614b\u3092\u66f4\u65b0\u3059\u308b\u305f\u3081\u306esetRecipes\u95a2\u6570\u3082\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001useEffect\u30d5\u30c3\u30af\u3067\u3001\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u305f\u3081\u306eHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u307e\u3059\u3002\u3053\u308c\u3092\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u300c~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\nconst Recipes = () =&gt; {\r\n  const navigate = useNavigate();\r\n  const [recipes, setRecipes] = useState([]);\r\n\r\n  <mark>useEffect(() =&gt; {<\/mark>\r\n    <mark>const url = \"\/api\/v1\/recipes\/index\";<\/mark>\r\n    <mark>fetch(url)<\/mark>\r\n      <mark>.then((res) =&gt; {<\/mark>\r\n        <mark>if (res.ok) {<\/mark>\r\n          <mark>return res.json();<\/mark>\r\n        <mark>}<\/mark>\r\n        <mark>throw new Error(\"Network response was not ok.\");<\/mark>\r\n      <mark>})<\/mark>\r\n      <mark>.then((res) =&gt; setRecipes(res))<\/mark>\r\n      <mark>.catch(() =&gt; navigate(\"\/\"));<\/mark>\r\n  <mark>}, []);<\/mark>\r\n};\r\n\r\nexport default Recipes;\r\n<\/code><\/pre>\n<p>\u3042\u306a\u305f\u306euseEffect\u30d5\u30c3\u30af\u3067\u306f\u3001Fetch API\u3092\u4f7f\u7528\u3057\u3066\u3059\u3079\u3066\u306e\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306bHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u307e\u3059\u3002\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30ec\u30b7\u30d4\u306e\u914d\u5217\u3092recipes\u30b9\u30c6\u30fc\u30c8\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u308b\u6642\u306b\u30d6\u30e9\u30a6\u30b6\u30da\u30fc\u30b8\u306b\u8a55\u4fa1\u304a\u3088\u3073\u8868\u793a\u3055\u308c\u308b\u8981\u7d20\u306e\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u30ec\u30b7\u30d4\u306e\u30ab\u30fc\u30c9\u3092\u30ec\u30b7\u30d4\u306e\u72b6\u614b\u304b\u3089\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002Recipes.jsx\u306b\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipes.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/\u30ec\u30b7\u30d4.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\nconst Recipes = () =&gt; {\r\n  const navigate = useNavigate();\r\n  const [recipes, setRecipes] = useState([]);\r\n\r\n  useEffect(() =&gt; {\r\n    const url = \"\/api\/v1\/recipes\/index\";\r\n    fetch(url)\r\n      .then((res) =&gt; {\r\n        if (res.ok) {\r\n          return res.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((res) =&gt; setRecipes(res))\r\n      .catch(() =&gt; navigate(\"\/\"));\r\n  }, []);\r\n\r\n  <mark>const allRecipes = recipes.map((recipe, index) =&gt; (<\/mark>\r\n    <mark>&lt;div key={index} className=\"col-md-6 col-lg-4\"&gt;<\/mark>\r\n      <mark>&lt;div className=\"card mb-4\"&gt;<\/mark>\r\n        <mark>&lt;img<\/mark>\r\n          <mark>src={recipe.image}<\/mark>\r\n          <mark>className=\"card-img-top\"<\/mark>\r\n          <mark>alt={`${recipe.name} image`}<\/mark>\r\n        <mark>\/&gt;<\/mark>\r\n        <mark>&lt;div className=\"card-body\"&gt;<\/mark>\r\n          <mark>&lt;h5 className=\"card-title\"&gt;{recipe.name}&lt;\/h5&gt;<\/mark>\r\n          <mark>&lt;Link to={`\/recipe\/${recipe.id}`} className=\"btn custom-button\"&gt;<\/mark>\r\n            <mark>View Recipe<\/mark>\r\n          <mark>&lt;\/Link&gt;<\/mark>\r\n        <mark>&lt;\/div&gt;<\/mark>\r\n      <mark>&lt;\/div&gt;<\/mark>\r\n    <mark>&lt;\/div&gt;<\/mark>\r\n  <mark>));<\/mark>\r\n  <mark>const noRecipe = (<\/mark>\r\n    <mark>&lt;div className=\"vw-100 vh-50 d-flex align-items-center justify-content-center\"&gt;<\/mark>\r\n      <mark>&lt;h4&gt;<\/mark>\r\n        <mark>No recipes yet. Why not &lt;Link to=\"\/new_recipe\"&gt;create one&lt;\/Link&gt;<\/mark>\r\n      <mark>&lt;\/h4&gt;<\/mark>\r\n    <mark>&lt;\/div&gt;<\/mark>\r\n  <mark>);<\/mark>\r\n\r\n  <mark>return (<\/mark>\r\n    <mark>&lt;&gt;<\/mark>\r\n      <mark>&lt;section className=\"jumbotron jumbotron-fluid text-center\"&gt;<\/mark>\r\n        <mark>&lt;div className=\"container py-5\"&gt;<\/mark>\r\n          <mark>&lt;h1 className=\"display-4\"&gt;Recipes for every occasion&lt;\/h1&gt;<\/mark>\r\n          <mark>&lt;p className=\"lead text-muted\"&gt;<\/mark>\r\n            <mark>We\u2019ve pulled together our most popular recipes, our latest<\/mark>\r\n            <mark>additions, and our editor\u2019s picks, so there\u2019s sure to be something<\/mark>\r\n            <mark>tempting for you to try.<\/mark>\r\n          <mark>&lt;\/p&gt;<\/mark>\r\n        <mark>&lt;\/div&gt;<\/mark>\r\n      <mark>&lt;\/section&gt;<\/mark>\r\n      <mark>&lt;div className=\"py-5\"&gt;<\/mark>\r\n        <mark>&lt;main className=\"container\"&gt;<\/mark>\r\n          <mark>&lt;div className=\"text-end mb-3\"&gt;<\/mark>\r\n            <mark>&lt;Link to=\"\/recipe\" className=\"btn custom-button\"&gt;<\/mark>\r\n              <mark>Create New Recipe<\/mark>\r\n            <mark>&lt;\/Link&gt;<\/mark>\r\n          <mark>&lt;\/div&gt;<\/mark>\r\n          <mark>&lt;div className=\"row\"&gt;<\/mark>\r\n            <mark>{recipes.length &gt; 0 ? allRecipes : noRecipe}<\/mark>\r\n          <mark>&lt;\/div&gt;<\/mark>\r\n          <mark>&lt;Link to=\"\/\" className=\"btn btn-link\"&gt;<\/mark>\r\n            <mark>Home<\/mark>\r\n          <mark>&lt;\/Link&gt;<\/mark>\r\n        <mark>&lt;\/main&gt;<\/mark>\r\n      <mark>&lt;\/div&gt;<\/mark>\r\n    <mark>&lt;\/&gt;<\/mark>\r\n  <mark>);<\/mark>\r\n};\r\n\r\nexport default Recipes;\r\n<\/code><\/pre>\n<p>\u300cRecipes.jsx\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/p>\n<p>\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u305f\u306e\u3067\u3001\u305d\u308c\u306b\u5bfe\u3059\u308b\u30eb\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308bapp\/javascript\/routes\/index.jsx\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/routes\/index.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u306b\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u307e\u3059\uff08\u4e00\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u307f\uff09\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { BrowserRouter as Router, Routes, Route } from \"react-router-dom\";\r\nimport Home from \"..\/components\/Home\";\r\n<mark>import Recipes from \"..\/components\/Recipes\";<\/mark>\r\n\r\nexport default (\r\n  &lt;Router&gt;\r\n    &lt;Routes&gt;\r\n      &lt;Route path=\"\/\" exact component={Home} \/&gt;\r\n      <mark>&lt;Route path=\"\/recipes\" element={&lt;Recipes \/&gt;} \/&gt;<\/mark>\r\n    &lt;\/Routes&gt;\r\n  &lt;\/Router&gt;\r\n);\r\n<\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u73fe\u6642\u70b9\u3067\u3001\u30b3\u30fc\u30c9\u304c\u4e88\u60f3\u3069\u304a\u308a\u306b\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u306e\u306f\u826f\u3044\u30a2\u30a4\u30c7\u30a2\u3067\u3059\u3002\u4ee5\u524d\u3068\u540c\u69d8\u306b\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\">bin\/dev<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30d7\u30ea\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u3067\u300c\u30ec\u30b7\u30d4\u3092\u8868\u793a\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u3001\u30b7\u30fc\u30c9\u30ec\u30b7\u30d4\u306e\u8868\u793a\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/249-0.png\" alt=\"Screencapture with the seed recipes page\" \/><\/div>\n<p>\u30b5\u30fc\u30d0\u30fc\u3092\u505c\u6b62\u3057\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u623b\u308b\u306b\u306f\u30bf\u30fc\u30df\u30ca\u30eb\u3067CTRL+C\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u5168\u3066\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u500b\u3005\u306e\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30bb\u30ab\u30f3\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002app\/javascript\/components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bRecipe.jsx\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/components\/Recipe.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u30ec\u30b7\u30d4\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u540c\u69d8\u306b\u3001\u4ee5\u4e0b\u306e\u884c\u3092\u8ffd\u52a0\u3057\u3066React\u3001useState\u3001useEffect\u3001Link\u3001useNavigate\u3001useParam\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u306e\u5185\u5bb9\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u300c~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u300d<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n<\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u3001Recipe\u3068\u3044\u3046\u6a5f\u80fd\u7684\u306aReact\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u9069\u8a33\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\n<mark>const Recipe = () =&gt; {<\/mark>\r\n  <mark>const params = useParams();<\/mark>\r\n  <mark>const navigate = useNavigate();<\/mark>\r\n  <mark>const [recipe, setRecipe] = useState({ ingredients: \"\" });<\/mark>\r\n<mark>};<\/mark>\r\n\r\n<mark>export default Recipe;<\/mark>\r\n<\/code><\/pre>\n<p>\u30ec\u30b7\u30d4\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u3088\u3046\u306b\u3001useNavigate\u30d5\u30c3\u30af\u3092\u4f7f\u3063\u3066React Router\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002useState\u30d5\u30c3\u30af\u3067\u30ec\u30b7\u30d4\u306e\u72b6\u614b\u3068setRecipe\u95a2\u6570\u3092\u4f7f\u3063\u3066\u72b6\u614b\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002\u3055\u3089\u306b\u3001useParams\u30d5\u30c3\u30af\u3092\u547c\u3073\u51fa\u3057\u3066URL\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u7279\u5b9a\u306e\u30ec\u30b7\u30d4\u3092\u63a2\u3059\u305f\u3081\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u305d\u306e\u30ec\u30b7\u30d4\u306eID\u3092\u77e5\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u30ec\u30b7\u30d4\u306eID\u30d1\u30e9\u30e1\u30fc\u30bf\u3092URL\u3067\u671f\u5f85\u3059\u308b\u3053\u3068\u304c\u3001\u30ec\u30b7\u30d4\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5f79\u5272\u3067\u3059\u3002useParams\u30d5\u30c3\u30af\u306e\u8fd4\u308a\u5024\u3092\u4fdd\u6301\u3059\u308bparams\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4ecb\u3057\u3066\u3053\u308c\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001params\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089id\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308buseEffect\u30d5\u30c3\u30af\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002\u30ec\u30b7\u30d4\u306eid\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3068\u3001\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306eHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx \u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306b\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059:<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\nconst Recipe = () =&gt; {\r\n  const params = useParams();\r\n  const navigate = useNavigate();\r\n  const [recipe, setRecipe] = useState({ ingredients: \"\" });\r\n\r\n  <mark>useEffect(() =&gt; {<\/mark>\r\n    <mark>const url = `\/api\/v1\/show\/${params.id}`;<\/mark>\r\n    <mark>fetch(url)<\/mark>\r\n      <mark>.then((response) =&gt; {<\/mark>\r\n        <mark>if (response.ok) {<\/mark>\r\n          <mark>return response.json();<\/mark>\r\n        <mark>}<\/mark>\r\n        <mark>throw new Error(\"Network response was not ok.\");<\/mark>\r\n      <mark>})<\/mark>\r\n      <mark>.then((response) =&gt; setRecipe(response))<\/mark>\r\n      <mark>.catch(() =&gt; navigate(\"\/recipes\"));<\/mark>\r\n  <mark>}, [params.id]);<\/mark>\r\n};\r\n\r\nexport default Recipe;\r\n<\/code><\/pre>\n<p>useEffect\u30d5\u30c3\u30af\u3067\u306f\u3001params.id\u306e\u5024\u3092\u4f7f\u7528\u3057\u3066GET HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u3001id\u3092\u6240\u6709\u3059\u308b\u30ec\u30b7\u30d4\u3092\u53d6\u5f97\u3057\u3001setRecipe\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u72b6\u614b\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002\u30ec\u30b7\u30d4\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u3001\u30a2\u30d7\u30ea\u306f\u30e6\u30fc\u30b6\u30fc\u3092\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001addHtmlEntities\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u306e\u95a2\u6570\u306f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5185\u306e\u6587\u5b57\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3092HTML\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3067\u7f6e\u304d\u63db\u3048\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002addHtmlEntities\u95a2\u6570\u306f\u3001\u6587\u5b57\u5217\u3092\u53d7\u3051\u53d6\u308a\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u305f\u958b\u304d\u304b\u3063\u3053\u3068\u9589\u3058\u304b\u3063\u3053\u3092HTML\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3067\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002\u3053\u306e\u95a2\u6570\u306f\u3001\u4fdd\u5b58\u3055\u308c\u305f\u30ec\u30b7\u30d4\u306e\u6307\u793a\u306b\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u305f\u6587\u5b57\u304c\u3042\u308c\u3070\u3001\u305d\u308c\u3092\u5909\u63db\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\nconst Recipe = () =&gt; {\r\n  const params = useParams();\r\n  const navigate = useNavigate();\r\n  const [recipe, setRecipe] = useState({ ingredients: \"\" });\r\n\r\n  useEffect(() =&gt; {\r\n    const url = `\/api\/v1\/show\/${params.id}`;\r\n    fetch(url)\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((response) =&gt; setRecipe(response))\r\n      .catch(() =&gt; navigate(\"\/recipes\"));\r\n  }, [params.id]);\r\n\r\n  <mark>const addHtmlEntities = (str) =&gt; {<\/mark>\r\n    <mark>return String(str).replace(\/&amp;lt;\/g, \"&lt;\").replace(\/&amp;gt;\/g, \"&gt;\");<\/mark>\r\n  <mark>};<\/mark>\r\n};\r\n\r\nexport default Recipe;\r\n\r\n<\/code><\/pre>\n<p>\u6700\u5f8c\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u30ec\u30b7\u30d4\u3092\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u72b6\u614b\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u305f\u3081\u306e\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u30da\u30fc\u30b8\u306b\u623b\u3057\u307e\u3059\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<br \/>\n\u301c\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\nconst Recipe = () =&gt; {\r\n  const params = useParams();\r\n  const navigate = useNavigate();\r\n  const [recipe, setRecipe] = useState({ ingredients: \"\" });\r\n\r\n  useEffect(() =&gt; {\r\n    const url = `\/api\/v1\/show\/${params.id}`;\r\n    fetch(url)\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((response) =&gt; setRecipe(response))\r\n      .catch(() =&gt; navigate(\"\/recipes\"));\r\n  }, [params.id]);\r\n\r\n  const addHtmlEntities = (str) =&gt; {\r\n    return String(str).replace(\/&amp;lt;\/g, \"&lt;\").replace(\/&amp;gt;\/g, \"&gt;\");\r\n  };\r\n\r\n  <mark>const ingredientList = () =&gt; {<\/mark>\r\n    <mark>let ingredientList = \"No ingredients available\";<\/mark>\r\n\r\n    <mark>if (recipe.ingredients.length &gt; 0) {<\/mark>\r\n      <mark>ingredientList = recipe.ingredients<\/mark>\r\n        <mark>.split(\",\")<\/mark>\r\n        <mark>.map((ingredient, index) =&gt; (<\/mark>\r\n          <mark>&lt;li key={index} className=\"list-group-item\"&gt;<\/mark>\r\n            <mark>{ingredient}<\/mark>\r\n          <mark>&lt;\/li&gt;<\/mark>\r\n        <mark>));<\/mark>\r\n    <mark>}<\/mark>\r\n\r\n    <mark>return ingredientList;<\/mark>\r\n  <mark>};<\/mark>\r\n\r\n  <mark>const recipeInstruction = addHtmlEntities(recipe.instruction);<\/mark>\r\n  \r\n  <mark>return (<\/mark>\r\n    <mark>&lt;div className=\"\"&gt;<\/mark>\r\n      <mark>&lt;div className=\"hero position-relative d-flex align-items-center justify-content-center\"&gt;<\/mark>\r\n        <mark>&lt;img<\/mark>\r\n          <mark>src={recipe.image}<\/mark>\r\n          <mark>alt={`${recipe.name} image`}<\/mark>\r\n          <mark>className=\"img-fluid position-absolute\"<\/mark>\r\n        <mark>\/&gt;<\/mark>\r\n        <mark>&lt;div className=\"overlay bg-dark position-absolute\" \/&gt;<\/mark>\r\n        <mark>&lt;h1 className=\"display-4 position-relative text-white\"&gt;<\/mark>\r\n          <mark>{recipe.name}<\/mark>\r\n        <mark>&lt;\/h1&gt;<\/mark>\r\n      <mark>&lt;\/div&gt;<\/mark>\r\n      <mark>&lt;div className=\"container py-5\"&gt;<\/mark>\r\n        <mark>&lt;div className=\"row\"&gt;<\/mark>\r\n          <mark>&lt;div className=\"col-sm-12 col-lg-3\"&gt;<\/mark>\r\n            <mark>&lt;ul className=\"list-group\"&gt;<\/mark>\r\n              <mark>&lt;h5 className=\"mb-2\"&gt;Ingredients&lt;\/h5&gt;<\/mark>\r\n              <mark>{ingredientList()}<\/mark>\r\n            <mark>&lt;\/ul&gt;<\/mark>\r\n          <mark>&lt;\/div&gt;<\/mark>\r\n          <mark>&lt;div className=\"col-sm-12 col-lg-7\"&gt;<\/mark>\r\n            <mark>&lt;h5 className=\"mb-2\"&gt;Preparation Instructions&lt;\/h5&gt;<\/mark>\r\n            <mark>&lt;div<\/mark>\r\n              <mark>dangerouslySetInnerHTML={{<\/mark>\r\n                <mark>__html: `${recipeInstruction}`,<\/mark>\r\n              <mark>}}<\/mark>\r\n            <mark>\/&gt;<\/mark>\r\n          <mark>&lt;\/div&gt;<\/mark>\r\n          <mark>&lt;div className=\"col-sm-12 col-lg-2\"&gt;<\/mark>\r\n            <mark>&lt;button<\/mark>\r\n              <mark>type=\"button\"<\/mark>\r\n              <mark>className=\"btn btn-danger\"<\/mark>\r\n            <mark>&gt;<\/mark>\r\n              <mark>Delete Recipe<\/mark>\r\n            <mark>&lt;\/button&gt;<\/mark>\r\n          <mark>&lt;\/div&gt;<\/mark>\r\n        <mark>&lt;\/div&gt;<\/mark>\r\n        <mark>&lt;Link to=\"\/recipes\" className=\"btn btn-link\"&gt;<\/mark>\r\n          <mark>Back to recipes<\/mark>\r\n        <mark>&lt;\/Link&gt;<\/mark>\r\n      <mark>&lt;\/div&gt;<\/mark>\r\n    <mark>&lt;\/div&gt;<\/mark>\r\n  <mark>);<\/mark>\r\n};\r\n\r\nexport default Recipe;\r\n<\/code><\/pre>\n<p>ingredientList\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ec\u30b7\u30d4\u306e\u98df\u6750\u3092\u30b3\u30f3\u30de\u3067\u533a\u5207\u3063\u3066\u914d\u5217\u306b\u5206\u5272\u3057\u3001\u305d\u306e\u914d\u5217\u3092\u30de\u30c3\u30d7\u3057\u3066\u98df\u6750\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3082\u3057\u98df\u6750\u304c\u306a\u3044\u5834\u5408\u3001\u30a2\u30d7\u30ea\u306f\u300c\u98df\u6750\u306f\u3042\u308a\u307e\u305b\u3093\u300d\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30ec\u30b7\u30d4\u306e\u6307\u793a\u306b\u3042\u308b\u5168\u3066\u306e\u958b\u304d\u30ab\u30c3\u30b3\u3068\u9589\u3058\u30ab\u30c3\u30b3\u3092addHtmlEntities\u95a2\u6570\u3092\u901a\u3057\u3066\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u30b3\u30fc\u30c9\u306f\u30ec\u30b7\u30d4\u753b\u50cf\u3092\u30d2\u30fc\u30ed\u30fc\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u8868\u793a\u3057\u3001\u30ec\u30b7\u30d4\u306e\u6307\u793a\u306e\u6a2a\u306b\u306f\u524a\u9664\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3057\u3001\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u623b\u308b\u305f\u3081\u306e\u30dc\u30bf\u30f3\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">Note<\/p>\n<div>\u6ce8\u610f\uff1aReact\u306edangerouslySetInnerHTML\u5c5e\u6027\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u5371\u967a\u3067\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u305d\u308c\u306b\u3088\u3063\u3066\u30a2\u30d7\u30ea\u304c\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0\u653b\u6483\u306b\u3055\u3089\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002\u3053\u306e\u30ea\u30b9\u30af\u3092\u8efd\u6e1b\u3059\u308b\u305f\u3081\u306b\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u5ba3\u8a00\u3055\u308c\u305fstripHtmlEntities\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ec\u30b7\u30d4\u4f5c\u6210\u6642\u306b\u5165\u529b\u3055\u308c\u305f\u7279\u6b8a\u6587\u5b57\u3092\u7f6e\u63db\u3057\u307e\u3059\u3002<\/div>\n<\/div>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30da\u30fc\u30b8\u4e0a\u306e\u30ec\u30b7\u30d4\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u8868\u793a\u3059\u308b\u306b\u306f\u3001\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u7de8\u96c6\u3059\u308b\u305f\u3081\u306b\u3001\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/routes\/index.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u6307\u793a\u3055\u308c\u305f\u90e8\u5206\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx\u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306b\u8a00\u3044\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\u305f\u3063\u305f\u4e00\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3060\u3051\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { BrowserRouter as Router, Routes, Route } from \"react-router-dom\";\r\nimport Home from \"..\/components\/Home\";\r\nimport Recipes from \"..\/components\/Recipes\";\r\n<mark>import Recipe from \"..\/components\/Recipe\";<\/mark>\r\n\r\nexport default (\r\n  &lt;Router&gt;\r\n    &lt;Routes&gt;\r\n      &lt;Route path=\"\/\" exact component={Home} \/&gt;\r\n      &lt;Route path=\"\/recipes\" exact component={Recipes} \/&gt;\r\n      <mark>&lt;Route path=\"\/recipe\/:id\" element={&lt;Recipe \/&gt;} \/&gt;<\/mark>\r\n    &lt;\/Routes&gt;\r\n  &lt;\/Router&gt;\r\n);\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001Recipe \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u30eb\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u306e\u30eb\u30fc\u30c8\u306b\u306f\u3001\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3057\u305f\u3044:id\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3001\u8868\u793a\u3057\u305f\u3044\u30ec\u30b7\u30d4\u306eid\u3067\u7f6e\u304d\u63db\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3059\u308b\u305f\u3081\u306b\u3001bin\/dev\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u7528\u3057\u3001\u305d\u306e\u5f8c\u30d6\u30e9\u30a6\u30b6\u3067http:\/\/localhost:3000\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3059\u308b\u305f\u3081\u306bView Recipes\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u3067\u306f\u3001\u8a73\u7d30\u3092\u898b\u308b\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3044\u305a\u308c\u304b\u306e\u30ec\u30b7\u30d4\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u306e\u60c5\u5831\u304c\u8a70\u307e\u3063\u305f\u30da\u30fc\u30b8\u3067\u8fce\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/282-0.png\" alt=\"Single Recipe Page\" \/><\/div>\n<p>CTRL+C\u3067\u30b5\u30fc\u30d0\u30fc\u3092\u505c\u6b62\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b9\u3064\u306e\u30ec\u30b7\u30d4\u3092\u8ffd\u52a0\u3057\u3001\u3053\u308c\u3089\u306e\u30ec\u30b7\u30d4\u3092\u500b\u5225\u306b\u304a\u3088\u3073\u307e\u3068\u3081\u3066\u8868\u793a\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d78 \u2014 \u30ec\u30b7\u30d4\u306e\u4f5c\u6210<\/h2>\n<p>\u4f7f\u3048\u308b\u98df\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u3092\u4f5c\u308b\u305f\u3081\u306e\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u306f\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u3053\u306e\u6a5f\u80fd\u306e\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304b\u3089\u5fc5\u8981\u306a\u30ec\u30b7\u30d4\u306e\u8a73\u7d30\u60c5\u5831\u3092\u53ce\u96c6\u3059\u308b\u305f\u3081\u306e\u30d5\u30a9\u30fc\u30e0\u304c\u542b\u307e\u308c\u3001\u305d\u306e\u5f8c\u3001Recipe\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u4f5c\u6210\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u30ec\u30b7\u30d4\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>app\/javascript\/components\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bNewRecipe.jsx\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/components\/NewRecipe.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4ed6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u4f7f\u7528\u3057\u305fReact\u3001useState\u3001Link\u3001\u304a\u3088\u3073useNavigate\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u4ee5\u4e0b\u306e\u3082\u306e\u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306b\u8a00\u3044\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u30021\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3060\u3051\u5fc5\u8981\u3067\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n<\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u3001\u6a5f\u80fd\u7684\u306aNewRecipe\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3066\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\uff1a<\/p>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>import React, { useState } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\n<mark>const NewRecipe = () =&gt; {<\/mark>\r\n  <mark>const navigate = useNavigate();<\/mark>\r\n  <mark>const [name, setName] = useState(\"\");<\/mark>\r\n  <mark>const [ingredients, setIngredients] = useState(\"\");<\/mark>\r\n  <mark>const [instruction, setInstruction] = useState(\"\");<\/mark>\r\n<mark>};<\/mark>\r\n\r\n<mark>export default NewRecipe;<\/mark>\r\n<\/code><\/pre>\n<p>\u4ee5\u524d\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u540c\u69d8\u306b\u3001useNavigate\u30d5\u30c3\u30af\u3092\u4f7f\u7528\u3057\u3066React\u30eb\u30fc\u30bf\u30fc\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3092\u521d\u671f\u5316\u3057\u3001useState\u30d5\u30c3\u30af\u3092\u4f7f\u7528\u3057\u3066\u540d\u524d\u3001\u6750\u6599\u3001\u624b\u9806\u306e\u72b6\u614b\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002\u5404\u72b6\u614b\u306b\u306f\u305d\u308c\u305e\u308c\u5bfe\u5fdc\u3059\u308b\u66f4\u65b0\u95a2\u6570\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306f\u6709\u52b9\u306a\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u7279\u6b8a\u6587\u5b57\uff08&lt;\u306a\u3069\uff09\u3092\u305d\u308c\u305e\u308c\u30a8\u30b9\u30b1\u30fc\u30d7\/\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u5024\uff08&lt;\u306a\u3069\uff09\u306b\u5909\u63db\u3059\u308bstripHtmlEntities\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u884c\u3046\u305f\u3081\u306b\u3001NewRecipe\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u4ee5\u4e0b\u306e\u5f37\u8abf\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>\u300c~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx\u300d\u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306a\u8868\u73fe\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<\/p>\n<p>\u300c~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx\u300d<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>import React, { useState } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\nconst NewRecipe = () =&gt; {\r\n  const navigate = useNavigate();\r\n  const [name, setName] = useState(\"\");\r\n  const [ingredients, setIngredients] = useState(\"\");\r\n  const [instruction, setInstruction] = useState(\"\");\r\n\r\n  <mark>const stripHtmlEntities = (str) =&gt; {<\/mark>\r\n    <mark>return String(str)<\/mark>\r\n      <mark>.replace(\/\\n\/g, \"&lt;br&gt; &lt;br&gt;\")<\/mark>\r\n      <mark>.replace(\/&lt;\/g, \"&amp;lt;\")<\/mark>\r\n      <mark>.replace(\/&gt;\/g, \"&amp;gt;\");<\/mark>\r\n  <mark>};<\/mark>\r\n};\r\n\r\nexport default NewRecipe;\r\n<\/code><\/pre>\n<p>stripHtmlEntities\u3068\u3044\u3046\u95a2\u6570\u3067\u306f\u3001&lt;\u3068&gt;\u306e\u6587\u5b57\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u305f\u5024\u3067\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u751f\u306eHTML\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001NewRecipe\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306bonChange\u3068onSubmit\u306e\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u7de8\u96c6\u3068\u9001\u4fe1\u3092\u51e6\u7406\u3059\u308b\u305f\u3081\u306b\u3001\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<p>\u4ee5\u4e0b\u306e\u6587\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\uff1a<\/p>\n<p>~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx<\/p>\n<\/div>\n<pre class=\"post-pre\"><code>import React, { useState } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\nconst NewRecipe = () =&gt; {\r\n  const navigate = useNavigate();\r\n  const [name, setName] = useState(\"\");\r\n  const [ingredients, setIngredients] = useState(\"\");\r\n  const [instruction, setInstruction] = useState(\"\");\r\n\r\n  const stripHtmlEntities = (str) =&gt; {\r\n    return String(str)\r\n      .replace(\/\\n\/g, \"&lt;br&gt; &lt;br&gt;\")\r\n      .replace(\/&lt;\/g, \"&amp;lt;\")\r\n      .replace(\/&gt;\/g, \"&amp;gt;\");\r\n  };\r\n\r\n  <mark>const onChange = (event, setFunction) =&gt; {<\/mark>\r\n    <mark>setFunction(event.target.value);<\/mark>\r\n  <mark>};<\/mark>\r\n\r\n  <mark>const onSubmit = (event) =&gt; {<\/mark>\r\n    <mark>event.preventDefault();<\/mark>\r\n    <mark>const url = \"\/api\/v1\/recipes\/create\";<\/mark>\r\n\r\n    <mark>if (name.length == 0 || ingredients.length == 0 || instruction.length == 0)<\/mark>\r\n      <mark>return;<\/mark>\r\n\r\n    <mark>const body = {<\/mark>\r\n      <mark>name,<\/mark>\r\n      <mark>ingredients,<\/mark>\r\n      <mark>instruction: stripHtmlEntities(instruction),<\/mark>\r\n    <mark>};<\/mark>\r\n\r\n    <mark>const token = document.querySelector('meta[name=\"csrf-token\"]').content;<\/mark>\r\n    <mark>fetch(url, {<\/mark>\r\n      <mark>method: \"POST\",<\/mark>\r\n      <mark>headers: {<\/mark>\r\n        <mark>\"X-CSRF-Token\": token,<\/mark>\r\n        <mark>\"Content-Type\": \"application\/json\",<\/mark>\r\n      <mark>},<\/mark>\r\n      <mark>body: JSON.stringify(body),<\/mark>\r\n    <mark>})<\/mark>\r\n      <mark>.then((response) =&gt; {<\/mark>\r\n        <mark>if (response.ok) {<\/mark>\r\n          <mark>return response.json();<\/mark>\r\n        <mark>}<\/mark>\r\n        <mark>throw new Error(\"Network response was not ok.\");<\/mark>\r\n      <mark>})<\/mark>\r\n      <mark>.then((response) =&gt; navigate(`\/recipe\/${response.id}`))<\/mark>\r\n      <mark>.catch((error) =&gt; console.log(error.message));<\/mark>\r\n  <mark>};<\/mark>\r\n};\r\n\r\nexport default NewRecipe;\r\n<\/code><\/pre>\n<p>onChange\u95a2\u6570\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u30a4\u30d9\u30f3\u30c8\u3068\u72b6\u614b\u306e\u8a2d\u5b9a\u95a2\u6570\u3092\u53d7\u3051\u53d6\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u5024\u3067\u72b6\u614b\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002onSubmit\u95a2\u6570\u3067\u306f\u3001\u5fc5\u9808\u306e\u5165\u529b\u9805\u76ee\u304c\u7a7a\u3067\u306a\u3044\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u542b\u3080\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002stripHtmlEntities\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ec\u30b7\u30d4\u306e\u6307\u793a\u306b\u542b\u307e\u308c\u308b&lt;\u3068&gt;\u306e\u6587\u5b57\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u305f\u5024\u306b\u7f6e\u304d\u63db\u3048\u3001\u6539\u884c\u6587\u5b57\u3092\u6539\u884c\u30bf\u30b0\u306b\u7f6e\u304d\u63db\u3048\u308b\u3053\u3068\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u5165\u529b\u3057\u305f\u30c6\u30ad\u30b9\u30c8\u306e\u5f62\u5f0f\u3092\u4fdd\u6301\u3057\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306ePOST HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u3001\u6210\u529f\u3057\u305f\u5834\u5408\u306b\u306f\u305d\u306e\u30ec\u30b7\u30d4\u306e\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>Rails\u306f\u3001Cross-Site Request Forgery\uff08CSRF\uff09\u653b\u6483\u304b\u3089\u306e\u4fdd\u8b77\u306e\u305f\u3081\u306b\u3001HTML\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306bCSRF\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30c8\u30fc\u30af\u30f3\u3092\u4ed8\u52a0\u3057\u307e\u3059\u3002\u3053\u306e\u30c8\u30fc\u30af\u30f3\u306f\u3001\u975eGET\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u884c\u308f\u308c\u308b\u305f\u3073\u306b\u5fc5\u8981\u3067\u3059\u3002\u524d\u8ff0\u306e\u30b3\u30fc\u30c9\u3067\u30c8\u30fc\u30af\u30f3\u304c\u5b9a\u6570\u3068\u3057\u3066\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u30c8\u30fc\u30af\u30f3\u3092\u691c\u8a3c\u3057\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30c8\u30fc\u30af\u30f3\u304c\u4e88\u60f3\u901a\u308a\u3067\u306a\u3044\u5834\u5408\u306f\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3057\u307e\u3059\u3002onSubmit\u95a2\u6570\u3067\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306fRails\u304c\u57cb\u3081\u8fbc\u3093\u3060HTML\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5185\u306eCSRF\u30c8\u30fc\u30af\u30f3\u3092\u53d6\u5f97\u3057\u3001JSON\u6587\u5b57\u5217\u3067HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u307e\u3059\u3002\u30ec\u30b7\u30d4\u304c\u6b63\u5e38\u306b\u4f5c\u6210\u3055\u308c\u308b\u3068\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30e6\u30fc\u30b6\u30fc\u3092\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3057\u3001\u65b0\u3057\u304f\u4f5c\u6210\u3055\u308c\u305f\u30ec\u30b7\u30d4\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u4f5c\u6210\u3057\u305f\u3044\u30ec\u30b7\u30d4\u306e\u8a73\u7d30\u3092\u5165\u529b\u3059\u308b\u305f\u3081\u306e\u30d5\u30a9\u30fc\u30e0\u3092\u8868\u793a\u3059\u308b\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u8fd4\u3057\u307e\u3059\u3002\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/NewRecipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u81ea\u7136\u306b\u8a00\u3044\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u30021\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3060\u3051\u5fc5\u8981\u3067\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>import React, { useState } from \"react\";\r\nimport { Link, useNavigate } from \"react-router-dom\";\r\n\r\nconst NewRecipe = () =&gt; {\r\n  const navigate = useNavigate();\r\n  const [name, setName] = useState(\"\");\r\n  const [ingredients, setIngredients] = useState(\"\");\r\n  const [instruction, setInstruction] = useState(\"\");\r\n\r\n  const stripHtmlEntities = (str) =&gt; {\r\n    return String(str)\r\n      .replace(\/\\n\/g, \"&lt;br&gt; &lt;br&gt;\")\r\n      .replace(\/&lt;\/g, \"&amp;lt;\")\r\n      .replace(\/&gt;\/g, \"&amp;gt;\");\r\n  };\r\n\r\n  const onChange = (event, setFunction) =&gt; {\r\n    setFunction(event.target.value);\r\n  };\r\n\r\n  const onSubmit = (event) =&gt; {\r\n    event.preventDefault();\r\n    const url = \"\/api\/v1\/recipes\/create\";\r\n\r\n    if (name.length == 0 || ingredients.length == 0 || instruction.length == 0)\r\n      return;\r\n\r\n    const body = {\r\n      name,\r\n      ingredients,\r\n      instruction: stripHtmlEntities(instruction),\r\n    };\r\n\r\n    const token = document.querySelector('meta[name=\"csrf-token\"]').content;\r\n    fetch(url, {\r\n      method: \"POST\",\r\n      headers: {\r\n        \"X-CSRF-Token\": token,\r\n        \"Content-Type\": \"application\/json\",\r\n      },\r\n      body: JSON.stringify(body),\r\n    })\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((response) =&gt; navigate(`\/recipe\/${response.id}`))\r\n      .catch((error) =&gt; console.log(error.message));\r\n  };\r\n\r\n  <mark>return (<\/mark>\r\n    <mark>&lt;div className=\"container mt-5\"&gt;<\/mark>\r\n      <mark>&lt;div className=\"row\"&gt;<\/mark>\r\n        <mark>&lt;div className=\"col-sm-12 col-lg-6 offset-lg-3\"&gt;<\/mark>\r\n          <mark>&lt;h1 className=\"font-weight-normal mb-5\"&gt;<\/mark>\r\n            <mark>Add a new recipe to our awesome recipe collection.<\/mark>\r\n          <mark>&lt;\/h1&gt;<\/mark>\r\n          <mark>&lt;form onSubmit={onSubmit}&gt;<\/mark>\r\n            <mark>&lt;div className=\"form-group\"&gt;<\/mark>\r\n              <mark>&lt;label htmlFor=\"recipeName\"&gt;Recipe name&lt;\/label&gt;<\/mark>\r\n              <mark>&lt;input<\/mark>\r\n                <mark>type=\"text\"<\/mark>\r\n                <mark>name=\"name\"<\/mark>\r\n                <mark>id=\"recipeName\"<\/mark>\r\n                <mark>className=\"form-control\"<\/mark>\r\n                <mark>required<\/mark>\r\n                <mark>onChange={(event) =&gt; onChange(event, setName)}<\/mark>\r\n              <mark>\/&gt;<\/mark>\r\n            <mark>&lt;\/div&gt;<\/mark>\r\n            <mark>&lt;div className=\"form-group\"&gt;<\/mark>\r\n              <mark>&lt;label htmlFor=\"recipeIngredients\"&gt;Ingredients&lt;\/label&gt;<\/mark>\r\n              <mark>&lt;input<\/mark>\r\n                <mark>type=\"text\"<\/mark>\r\n                <mark>name=\"ingredients\"<\/mark>\r\n                <mark>id=\"recipeIngredients\"<\/mark>\r\n                <mark>className=\"form-control\"<\/mark>\r\n                <mark>required<\/mark>\r\n                <mark>onChange={(event) =&gt; onChange(event, setIngredients)}<\/mark>\r\n              <mark>\/&gt;<\/mark>\r\n              <mark>&lt;small id=\"ingredientsHelp\" className=\"form-text text-muted\"&gt;<\/mark>\r\n                <mark>Separate each ingredient with a comma.<\/mark>\r\n              <mark>&lt;\/small&gt;<\/mark>\r\n            <mark>&lt;\/div&gt;<\/mark>\r\n            <mark>&lt;label htmlFor=\"instruction\"&gt;Preparation Instructions&lt;\/label&gt;<\/mark>\r\n            <mark>&lt;textarea<\/mark>\r\n              <mark>className=\"form-control\"<\/mark>\r\n              <mark>id=\"instruction\"<\/mark>\r\n              <mark>name=\"instruction\"<\/mark>\r\n              <mark>rows=\"5\"<\/mark>\r\n              <mark>required<\/mark>\r\n              <mark>onChange={(event) =&gt; onChange(event, setInstruction)}<\/mark>\r\n            <mark>\/&gt;<\/mark>\r\n            <mark>&lt;button type=\"submit\" className=\"btn custom-button mt-3\"&gt;<\/mark>\r\n              <mark>Create Recipe<\/mark>\r\n            <mark>&lt;\/button&gt;<\/mark>\r\n            <mark>&lt;Link to=\"\/recipes\" className=\"btn btn-link mt-3\"&gt;<\/mark>\r\n              <mark>Back to recipes<\/mark>\r\n            <mark>&lt;\/Link&gt;<\/mark>\r\n          <mark>&lt;\/form&gt;<\/mark>\r\n        <mark>&lt;\/div&gt;<\/mark>\r\n      <mark>&lt;\/div&gt;<\/mark>\r\n    <mark>&lt;\/div&gt;<\/mark>\r\n  <mark>);<\/mark>\r\n};\r\n\r\nexport default NewRecipe;\r\n<\/code><\/pre>\n<p>\u8fd4\u3055\u308c\u308b\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u306b\u306f\u30013\u3064\u306e\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\uff08recipeName\u3001recipeIngredients\u3001instruction\u305d\u308c\u305e\u308c\u306b1\u3064\u305a\u3064\uff09\u3092\u542b\u3093\u3060\u30d5\u30a9\u30fc\u30e0\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u5404\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u306f\u3001onChange\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u304c\u3042\u308a\u3001\u305d\u308c\u306fonChange\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002\u307e\u305f\u3001submit\u30dc\u30bf\u30f3\u306b\u306fonSubmit\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u304c\u4ed8\u3044\u3066\u304a\u308a\u3001\u30d5\u30a9\u30fc\u30e0\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308bonSubmit\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u3001\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057\u3066\u305d\u306e\u30eb\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/routes\/index.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4e0b\u7dda\u90e8\u5206\u3092\u542b\u3081\u3066\u3001\u81ea\u5206\u306e\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\u300c~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx\u300d\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059:<br \/>\n\u300c~\/rails_react_recipe\/app\/javascript\/routes\/index.jsx\u300d<\/div>\n<pre class=\"post-pre\"><code>import React from \"react\";\r\nimport { BrowserRouter as Router, Routes, Route } from \"react-router-dom\";\r\nimport Home from \"..\/components\/Home\";\r\nimport Recipes from \"..\/components\/Recipes\";\r\nimport Recipe from \"..\/components\/Recipe\";\r\n<mark>import NewRecipe from \"..\/components\/NewRecipe\";<\/mark>\r\n\r\nexport default (\r\n  &lt;Router&gt;\r\n    &lt;Routes&gt;\r\n      &lt;Route path=\"\/\" exact component={Home} \/&gt;\r\n      &lt;Route path=\"\/recipes\" exact component={Recipes} \/&gt;\r\n      &lt;Route path=\"\/recipe\/:id\" exact component={Recipe} \/&gt;\r\n      <mark>&lt;Route path=\"\/recipe\" element={&lt;NewRecipe \/&gt;} \/&gt;<\/mark>\r\n    &lt;\/Routes&gt;\r\n  &lt;\/Router&gt;\r\n);\r\n<\/code><\/pre>\n<p>\u30eb\u30fc\u30c8\u304c\u78ba\u5b9a\u3057\u305f\u3089\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u958b\u767a\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3057\u3001\u30d6\u30e9\u30a6\u30b6\u3067http:\/\/localhost:3000\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3057\u3001\u65b0\u3057\u3044\u30ec\u30b7\u30d4\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30ec\u30b7\u30d4\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u30d5\u30a9\u30fc\u30e0\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/317-0.png\" alt=\"Create Recipe Page\" \/><\/div>\n<p>\u5fc5\u8981\u306a\u30ec\u30b7\u30d4\u306e\u8a73\u7d30\u3092\u5165\u529b\u3057\u3066\u3001\u300c\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3059\u308b\u3068\u3001\u65b0\u3057\u304f\u4f5c\u6210\u3055\u308c\u305f\u30ec\u30b7\u30d4\u304c\u30da\u30fc\u30b8\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u3001\u30b5\u30fc\u30d0\u30fc\u3092\u9589\u3058\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u98df\u4e8b\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u306b\u30ec\u30b7\u30d4\u3092\u4f5c\u6210\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u3001\u30ec\u30b7\u30d4\u3092\u524a\u9664\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c6\u30c3\u30d79 \u2014 \u30ec\u30b7\u30d4\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30ec\u30b7\u30d4\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5909\u66f4\u3057\u3066\u3001\u30ec\u30b7\u30d4\u3092\u524a\u9664\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u3067\u524a\u9664\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30ec\u30b7\u30d4\u3092\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u521d\u306b\u3001\u7de8\u96c6\u306e\u305f\u3081\u306bRecipe.jsx\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"$\"><span class=\"token function\">nano<\/span> app\/javascript\/components\/Recipe.jsx<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u300c\u30ec\u30b7\u30d4\u300d\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3001\u4ee5\u4e0b\u306e\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u305f\u884c\u3092\u542b\u3080\u300cdeleteRecipe\u300d\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx \u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\nconst Recipe = () =&gt; {\r\n  const params = useParams();\r\n  const navigate = useNavigate();\r\n  const [recipe, setRecipe] = useState({ ingredients: \"\" });\r\n\r\n  useEffect(() =&gt; {\r\n    const url = `\/api\/v1\/show\/${params.id}`;\r\n    fetch(url)\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((response) =&gt; setRecipe(response))\r\n      .catch(() =&gt; navigate(\"\/recipes\"));\r\n  }, [params.id]);\r\n\r\n  const addHtmlEntities = (str) =&gt; {\r\n    return String(str).replace(\/&amp;lt;\/g, \"&lt;\").replace(\/&amp;gt;\/g, \"&gt;\");\r\n  };\r\n\r\n  <mark>const deleteRecipe = () =&gt; {<\/mark>\r\n    <mark>const url = `\/api\/v1\/destroy\/${params.id}`;<\/mark>\r\n    <mark>const token = document.querySelector('meta[name=\"csrf-token\"]').content;<\/mark>\r\n\r\n    <mark>fetch(url, {<\/mark>\r\n      <mark>method: \"DELETE\",<\/mark>\r\n      <mark>headers: {<\/mark>\r\n        <mark>\"X-CSRF-Token\": token,<\/mark>\r\n        <mark>\"Content-Type\": \"application\/json\",<\/mark>\r\n      <mark>},<\/mark>\r\n    <mark>})<\/mark>\r\n      <mark>.then((response) =&gt; {<\/mark>\r\n        <mark>if (response.ok) {<\/mark>\r\n          <mark>return response.json();<\/mark>\r\n        <mark>}<\/mark>\r\n        <mark>throw new Error(\"Network response was not ok.\");<\/mark>\r\n      <mark>})<\/mark>\r\n      <mark>.then(() =&gt; navigate(\"\/recipes\"))<\/mark>\r\n      <mark>.catch((error) =&gt; console.log(error.message));<\/mark>\r\n  <mark>};<\/mark>\r\n\r\n  const ingredientList = () =&gt; {\r\n    let ingredientList = \"No ingredients available\";\r\n\r\n    if (recipe.ingredients.length &gt; 0) {\r\n      ingredientList = recipe.ingredients\r\n        .split(\",\")\r\n        .map((ingredient, index) =&gt; (\r\n          &lt;li key={index} className=\"list-group-item\"&gt;\r\n            {ingredient}\r\n          &lt;\/li&gt;\r\n        ));\r\n    }\r\n\r\n    return ingredientList;\r\n  };\r\n\r\n  const recipeInstruction = addHtmlEntities(recipe.instruction);\r\n\r\n  return (\r\n    &lt;div className=\"\"&gt;\r\n...\r\n<\/code><\/pre>\n<p>deleteRecipe\u95a2\u6570\u3067\u306f\u3001\u524a\u9664\u3059\u308b\u30ec\u30b7\u30d4\u306eID\u3092\u53d6\u5f97\u3057\u3001URL\u3092\u69cb\u7bc9\u3057\u3066CSRF\u30c8\u30fc\u30af\u30f3\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u6b21\u306b\u3001Recipes\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306bDELETE\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u3001\u30ec\u30b7\u30d4\u3092\u524a\u9664\u3057\u307e\u3059\u3002\u3082\u3057\u30ec\u30b7\u30d4\u306e\u524a\u9664\u304c\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30e6\u30fc\u30b6\u30fc\u3092\u30ec\u30b7\u30d4\u4e00\u89a7\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>delete\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306bdeleteRecipe\u95a2\u6570\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u3001\u30dc\u30bf\u30f3\u306b\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3068\u3057\u3066\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306edelete\u30dc\u30bf\u30f3\u8981\u7d20\u306bonClick\u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx \u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068 \u300c~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/div>\n<pre class=\"post-pre\"><code>...\r\nreturn (\r\n    &lt;div className=\"\"&gt;\r\n      &lt;div className=\"hero position-relative d-flex align-items-center justify-content-center\"&gt;\r\n        &lt;img\r\n          src={recipe.image}\r\n          alt={`${recipe.name} image`}\r\n          className=\"img-fluid position-absolute\"\r\n        \/&gt;\r\n        &lt;div className=\"overlay bg-dark position-absolute\" \/&gt;\r\n        &lt;h1 className=\"display-4 position-relative text-white\"&gt;\r\n          {recipe.name}\r\n        &lt;\/h1&gt;\r\n      &lt;\/div&gt;\r\n      &lt;div className=\"container py-5\"&gt;\r\n        &lt;div className=\"row\"&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-3\"&gt;\r\n            &lt;ul className=\"list-group\"&gt;\r\n              &lt;h5 className=\"mb-2\"&gt;Ingredients&lt;\/h5&gt;\r\n              {ingredientList()}\r\n            &lt;\/ul&gt;\r\n          &lt;\/div&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-7\"&gt;\r\n            &lt;h5 className=\"mb-2\"&gt;Preparation Instructions&lt;\/h5&gt;\r\n            &lt;div\r\n              dangerouslySetInnerHTML={{\r\n                __html: `${recipeInstruction}`,\r\n              }}\r\n            \/&gt;\r\n          &lt;\/div&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-2\"&gt;\r\n            &lt;button\r\n              type=\"button\"\r\n              className=\"btn btn-danger\"\r\n              <mark>onClick={deleteRecipe}<\/mark>\r\n            &gt;\r\n              Delete Recipe\r\n            &lt;\/button&gt;\r\n          &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        &lt;Link to=\"\/recipes\" className=\"btn btn-link\"&gt;\r\n          Back to recipes\r\n        &lt;\/Link&gt;\r\n      &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n  );\r\n...\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u3053\u306e\u6642\u70b9\u3067\u3001\u5b8c\u5168\u306aRecipe.jsx\u30d5\u30a1\u30a4\u30eb\u306f\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u4e00\u81f4\u3057\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<div>~\/rails_react_recipe\/app\/javascript\/components\/Recipe.jsx\u3092\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff1a<br \/>\n~\/rails_react_recipe\/app\/javascript\/components\/\u30ec\u30b7\u30d4.jsx<\/div>\n<pre class=\"post-pre\"><code>import React, { useState, useEffect } from \"react\";\r\nimport { Link, useNavigate, useParams } from \"react-router-dom\";\r\n\r\nconst Recipe = () =&gt; {\r\n  const params = useParams();\r\n  const navigate = useNavigate();\r\n  const [recipe, setRecipe] = useState({ ingredients: \"\" });\r\n\r\n  useEffect(() =&gt; {\r\n    const url = `\/api\/v1\/show\/${params.id}`;\r\n    fetch(url)\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then((response) =&gt; setRecipe(response))\r\n      .catch(() =&gt; navigate(\"\/recipes\"));\r\n  }, [params.id]);\r\n\r\n  const addHtmlEntities = (str) =&gt; {\r\n    return String(str).replace(\/&amp;lt;\/g, \"&lt;\").replace(\/&amp;gt;\/g, \"&gt;\");\r\n  };\r\n\r\n  const deleteRecipe = () =&gt; {\r\n    const url = `\/api\/v1\/destroy\/${params.id}`;\r\n    const token = document.querySelector('meta[name=\"csrf-token\"]').content;\r\n\r\n    fetch(url, {\r\n      method: \"DELETE\",\r\n      headers: {\r\n        \"X-CSRF-Token\": token,\r\n        \"Content-Type\": \"application\/json\",\r\n      },\r\n    })\r\n      .then((response) =&gt; {\r\n        if (response.ok) {\r\n          return response.json();\r\n        }\r\n        throw new Error(\"Network response was not ok.\");\r\n      })\r\n      .then(() =&gt; navigate(\"\/recipes\"))\r\n      .catch((error) =&gt; console.log(error.message));\r\n  };\r\n\r\n  const ingredientList = () =&gt; {\r\n    let ingredientList = \"No ingredients available\";\r\n\r\n    if (recipe.ingredients.length &gt; 0) {\r\n      ingredientList = recipe.ingredients\r\n        .split(\",\")\r\n        .map((ingredient, index) =&gt; (\r\n          &lt;li key={index} className=\"list-group-item\"&gt;\r\n            {ingredient}\r\n          &lt;\/li&gt;\r\n        ));\r\n    }\r\n\r\n    return ingredientList;\r\n  };\r\n\r\n  const recipeInstruction = addHtmlEntities(recipe.instruction);\r\n\r\n  return (\r\n    &lt;div className=\"\"&gt;\r\n      &lt;div className=\"hero position-relative d-flex align-items-center justify-content-center\"&gt;\r\n        &lt;img\r\n          src={recipe.image}\r\n          alt={`${recipe.name} image`}\r\n          className=\"img-fluid position-absolute\"\r\n        \/&gt;\r\n        &lt;div className=\"overlay bg-dark position-absolute\" \/&gt;\r\n        &lt;h1 className=\"display-4 position-relative text-white\"&gt;\r\n          {recipe.name}\r\n        &lt;\/h1&gt;\r\n      &lt;\/div&gt;\r\n      &lt;div className=\"container py-5\"&gt;\r\n        &lt;div className=\"row\"&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-3\"&gt;\r\n            &lt;ul className=\"list-group\"&gt;\r\n              &lt;h5 className=\"mb-2\"&gt;Ingredients&lt;\/h5&gt;\r\n              {ingredientList()}\r\n            &lt;\/ul&gt;\r\n          &lt;\/div&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-7\"&gt;\r\n            &lt;h5 className=\"mb-2\"&gt;Preparation Instructions&lt;\/h5&gt;\r\n            &lt;div\r\n              dangerouslySetInnerHTML={{\r\n                __html: `${recipeInstruction}`,\r\n              }}\r\n            \/&gt;\r\n          &lt;\/div&gt;\r\n          &lt;div className=\"col-sm-12 col-lg-2\"&gt;\r\n            &lt;button\r\n              type=\"button\"\r\n              className=\"btn btn-danger\"\r\n              onClick={deleteRecipe}\r\n            &gt;\r\n              Delete Recipe\r\n            &lt;\/button&gt;\r\n          &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        &lt;Link to=\"\/recipes\" className=\"btn btn-link\"&gt;\r\n          Back to recipes\r\n        &lt;\/Link&gt;\r\n      &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n  );\r\n};\r\n\r\nexport default Recipe;\r\n<\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3001\u7d42\u4e86\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3057\u3001\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3059\u3079\u3066\u306e\u65e2\u5b58\u306e\u30ec\u30b7\u30d4\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u300c\u30ec\u30b7\u30d4\u3092\u8868\u793a\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u305d\u306e\u5f8c\u3001\u4efb\u610f\u306e\u30ec\u30b7\u30d4\u3092\u958b\u3044\u3066\u300c\u30ec\u30b7\u30d4\u3092\u524a\u9664\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u8a18\u4e8b\u3092\u524a\u9664\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u524a\u9664\u3057\u305f\u30ec\u30b7\u30d4\u306f\u5b58\u5728\u3057\u306a\u304f\u306a\u308a\u3001\u30ec\u30b7\u30d4\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u524a\u9664\u30dc\u30bf\u30f3\u304c\u6a5f\u80fd\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u5b8c\u5168\u306b\u6a5f\u80fd\u3059\u308b\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u3092\u624b\u306b\u5165\u308c\u307e\u3057\u305f\uff01<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Ruby on Rails\u3068React\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u98df\u54c1\u30ec\u30b7\u30d4\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306fPostgreSQL\u3092\u4f7f\u7528\u3057\u3001\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u306b\u306fBootstrap\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002\u3082\u3057Ruby on Rails\u3067\u306e\u958b\u767a\u3092\u7d9a\u3051\u305f\u3044\u5834\u5408\u306f\u3001SSH\u30c8\u30f3\u30cd\u30eb\u3092\u4f7f\u7528\u3057\u305f\u4e09\u5c64Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u901a\u4fe1\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u53c2\u8003\u306b\u3059\u308b\u304b\u3001Ruby\u306e\u30b9\u30ad\u30eb\u3092\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u3059\u308b\u305f\u3081\u306b\u5f53\u793e\u306eRuby\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30b7\u30ea\u30fc\u30ba\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002React\u306b\u3064\u3044\u3066\u3055\u3089\u306b\u6df1\u304f\u5b66\u3073\u305f\u3044\u5834\u5408\u306f\u3001Silicon Cloud API\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3059\u308bReact\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b46\u8005\u306f\u3001Write for Donations\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e00\u74b0\u3068\u3057\u3066\u3001\u5bc4\u4ed8\u91d1\u3092\u53d7\u3051\u53d6\u308b\u56e3\u4f53\u3068\u3057\u3066Electronic Frontier Foundation\u3092\u9078\u3073\u307e\u3057\u305f\u3002 \u30a4\u30f3\u30c8\u30ed\u30c0\u30af\u30b7\u30e7\u30f3 Ruby on Rails\u306f [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,18],"class_list":["post-980","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux","tag-18"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/\u300cubuntu-20-04-\u4e0a\u3067-ruby-on-rails-v7-\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001react-\u30d5\u30ed\u30f3\u30c8\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\" \/>\n<meta property=\"og:description\" content=\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/\u300cubuntu-20-04-\u4e0a\u3067-ruby-on-rails-v7-\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001react-\u30d5\u30ed\u30f3\u30c8\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-01T07:33:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T19:01:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/6-0.png\" \/>\n<meta name=\"author\" content=\"\u590f\u6a39, \u98a8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u590f\u6a39, \u98a8\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"128\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/\",\"name\":\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-04-01T07:33:55+00:00\",\"dateModified\":\"2025-07-31T19:01:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\"},\"description\":\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\",\"name\":\"\u590f\u6a39, \u98a8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"caption\":\"\u590f\u6a39, \u98a8\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d - Blog - Silicon Cloud","description":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/\u300cubuntu-20-04-\u4e0a\u3067-ruby-on-rails-v7-\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001react-\u30d5\u30ed\u30f3\u30c8\/","og_locale":"ja_JP","og_type":"article","og_title":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d","og_description":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/\u300cubuntu-20-04-\u4e0a\u3067-ruby-on-rails-v7-\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001react-\u30d5\u30ed\u30f3\u30c8\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-04-01T07:33:55+00:00","article_modified_time":"2025-07-31T19:01:11+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656460ebdaa94e2bdf7b2f3a\/6-0.png"}],"author":"\u590f\u6a39, \u98a8","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u590f\u6a39, \u98a8","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"128\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/","name":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-04-01T07:33:55+00:00","dateModified":"2025-07-31T19:01:11+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d"},"description":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"\u300cUbuntu 20.04 \u4e0a\u3067 Ruby on Rails v7 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001React \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u300d"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d","name":"\u590f\u6a39, \u98a8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","caption":"\u590f\u6a39, \u98a8"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e3%80%8cubuntu-20-04-%e4%b8%8a%e3%81%a7-ruby-on-rails-v7-%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%80%81react-%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=980"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/980\/revisions"}],"predecessor-version":[{"id":47513,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/980\/revisions\/47513"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}