{"id":2774,"date":"2021-11-07T20:05:37","date_gmt":"2021-11-07T11:05:37","guid":{"rendered":"https:\/\/suzutukiblog.com\/?p=2774"},"modified":"2022-01-21T02:21:57","modified_gmt":"2022-01-20T17:21:57","slug":"rails-7","status":"publish","type":"post","link":"https:\/\/suzutukiblog.com\/index.php\/2021\/11\/07\/rails-7\/","title":{"rendered":"Rails\u306e\u307e\u3068\u30813(\u30df\u30cbQ&#038;A\u30b5\u30a4\u30c8\u3092\u4f5c\u308b\u305d\u306e\uff11)"},"content":{"rendered":"<p><a href=\"https:\/\/suzutukiblog.com\/index.php\/2021\/04\/13\/rails-6\/\">\u305d\u306e2\u304b\u3089\u7d9a\u304f<\/a><\/p>\n<h1>\u30df\u30cbQ&amp;A\u30a2\u30d7\u30ea\u3092\u4f5c\u308d\u3046\uff01<\/h1>\n<p>\u958b\u767a\u74b0\u5883\u306fCloud9\u3067\u884c\u3046<\/p>\n<h3>0:\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3092\u3057\u307e\u3059\u3002<\/h3>\n<pre><strong>sudo yum update<\/strong><\/pre>\n<h3>Ruby\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<\/h3>\n<pre><strong>rvm -v<\/strong>\r\n<strong>rvm install 2.5.1<\/strong>\r\n<strong>rvm install 2.6.4<\/strong>\r\n<strong>rvm list<\/strong>\r\n\r\nruby2.5.1\u3092\u4f7f\u3046\r\n\r\n<strong>rvm use 2.5.1<\/strong>\r\n\r\n\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d\r\n\r\n<strong>ruby -v<\/strong>\r\n\r\n2.5.1\u3092\u30c7\u30d5\u30a9\u3067\u4f7f\u3044\u305f\u3044\u3068\u304d\r\n\r\n<strong>rvm --default use 2.5.1<\/strong>\r\n\r\n<strong>rvm list<\/strong>\r\n<\/pre>\n<h3>1\uff1a\u307e\u305a\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/h3>\n<pre><strong>cd ~\/environment\/rails_projects\r\nls\r\nrails -v\r\nruby -v\r\nrails _5.2.1_ new qa<\/strong><\/pre>\n<p>\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u306bgemfile\u306esqlite3\u306e\u90e8\u5206\u3092\u8ffd\u52a0\u2193<\/p>\n<pre><strong>gem 'sqlite3', '~&gt; 1.3.6'\r\n\r\n# ~\/environment\/rails_projects\/hello\u306b\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057sqlite3\u3092\u30a2\u30d7\u30c7\r\n\r\nbundle update<\/strong><\/pre>\n<h3>2\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n<pre><strong>rails db:create\r\n\r\n\u30ec\u30a4\u30eb\u30ba\u30b5\u30fc\u30d0\u30fc\u8d77\u52d5\r\nrails s<\/strong><\/pre>\n<p>localhost\u3067\u2193\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u78ba\u8a8d\u3067\u304d\u308c\u3070OK<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2769\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/24448c31b002fb0882e7d5ddf764ff9c.png\" alt=\"\" width=\"862\" height=\"760\" srcset=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/24448c31b002fb0882e7d5ddf764ff9c.png 862w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/24448c31b002fb0882e7d5ddf764ff9c-300x265.png 300w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/24448c31b002fb0882e7d5ddf764ff9c-768x677.png 768w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/24448c31b002fb0882e7d5ddf764ff9c-624x550.png 624w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/p>\n<p><!--more--><\/p>\n<h3>3\uff1a\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210 MVC\u306eC<\/h3>\n<pre>#questions\u3068\u3044\u3046\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u2193\u3092\u4f5c\u6210\r\n<strong>rails g controller questions index show new edit<\/strong>\r\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000#\u4fdd\u6709\u3059\u308b\u30a2\u30af\u30b7\u30e7\u30f3\u2191\r\nindex\u306f\u8cea\u554f\u306e\u4e00\u89a7\u8868\u793a\r\nshow\u306f\u8a73\u7d30\u78ba\u8a8d\r\nnew\u306f\u65b0\u898f\u4f5c\u6210\r\nedit\u306f\u7de8\u96c6\u62c5\u5f53<\/pre>\n<p><strong>app\/controller\/questions_controlle<\/strong>r\u3067<br \/>\n\u2193\u306e\u3088\u3046\u306b\u305d\u308c\u305e\u308c\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3067\u304d\u3066\u3044\u308b\uff01\uff01<\/p>\n<pre><strong>class QuestionsController &lt; ApplicationController\r\n  def index\r\n  end\r\n\r\n  def show\r\n  end\r\n\r\n  def new\r\n  end\r\n\r\n  def edit\r\n  end\r\nend<\/strong><\/pre>\n<p>\u66f4\u306b<strong>app\/views\/questions<\/strong>\u306e\u4e2d\u306b<br \/>\nedit.html.erb, index.html.erb, new.html.erb, show.html.erb<\/p>\n<p>\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<h3>4:question\u30e2\u30c7\u30eb\u306e\u4f5c\u6210\u3000MVC\u306eM<\/h3>\n<p>question\u3068\u3044\u3046\u540d\u2193\u306e\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3000\u3000\u2193\u30c7\u30fc\u30bf\u30fb\u30d9\u30fc\u30b9\u306e\u30ab\u30e9\u30e0\u306e\u60c5\u5831\u306e\u5b9a\u7fa9<\/p>\n<pre><strong>rails g model question name:string title:string content:text\r\n<\/strong>\r\nname:\u6295\u7a3f\u8005\u306e\u540d\u524d\u3092string\u578b\u3000:\u8cea\u554f\u306e\u30bf\u30a4\u30c8\u30eb\u3092string\u578b \u8cea\u554f\u306e\u672c\u6587\u3092text\u578b\u306b\u3057\u3066\u3044\u308b\r\n\r\ndb\/migrate\/20210103\u306e\u3068\u3053\u308d\u306b\u3044\u304f\r\n\u4e0a\u8a18\u306e\u8a2d\u5b9a\u304c\u53cd\u6620\u3055\u308c\u3066\u3044\u307e\u3059\u3002\r\n\r\n<strong>class CreateQuestions &lt; ActiveRecord::Migration[5.2]\r\n  def change\r\n    create_table :questions do |t|\r\n      t.string :name\r\n      t.string :title\r\n      t.text :content\r\n      t.timestamps\r\n    end\r\n  end\r\nend<\/strong><\/pre>\n<p>\u30b9\u30da\u30eb\u30df\u30b9\u304c\u306a\u3044\u304b\u6ce8\u610f\u3059\u308b\u3053\u3068\uff01\uff01<\/p>\n<h3>5\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u9001\u308b(\u30de\u30a4\u30b0\u30ec\u30fc\u30c8)<\/h3>\n<pre><strong>rails db:migrate<\/strong><\/pre>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>rails dbconsole\r\n.schema<\/strong>\r\n\u2193\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308c\u3070OK\r\n<strong>CREATE TABLE \"questions\" (\"id\" integer PRIMARY KEY AUTOINCREMENT NOT NULL, \"name\" varchar, \"title\" varchar, \"content\" text, \"created_at\" datetime NOT NULL, \"updated_at\" datetime NOT NULL);\r\n<\/strong>.q\u3067\u623b\u308b<\/pre>\n<p>rails s\u3000\u3067\u30b5\u30fc\u30d0\u30fc\u8d77\u52d5\u3057\u3066URL\u306b\u30a2\u30af\u30bb\u30b9\u2193<\/p>\n<p>Questions#index<br \/>\nFind me in app\/views\/questions\/index.html.erb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2788\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a.png\" alt=\"\" width=\"1134\" height=\"666\" srcset=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a.png 1134w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a-300x176.png 300w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a-1024x601.png 1024w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a-768x451.png 768w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/68180b59bd2c9ff20078ada7acee099a-624x366.png 624w\" sizes=\"auto, (max-width: 1134px) 100vw, 1134px\" \/><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308c\u3070OK<br \/>\n\u2191\u306fapp\/views\/questions\/index.html.erb\u306e\u5185\u5bb9\u3092\u8868\u793a\u3057\u3066\u3044\u308b\u3088<\/p>\n<h3>6\uff1a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a<\/h3>\n<pre><strong>rails routes\r\n<\/strong>\r\n<strong>questions_index GET \/questions\/index(.:format) questions#index\r\n<\/strong>\u2191\/questions\/index\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304dquestions\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\r\n\r\nindex\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u3059\u308b\u3068\u3044\u3046\u3053\u3068\r\n\r\n<\/pre>\n<p>config\/routes.rb\u306b\u3066<\/p>\n<pre><strong>Rails.application.routes.draw do\r\n# get 'questions\/index'\r\n# get 'questions\/show'\r\n# get 'questions\/new'\r\n# get 'questions\/edit'\r\n\r\nresources :questions\r\n# For details on the DSL available within this file, see http:\/\/guides.rubyonrails.org\/routing.html\r\nend<\/strong><\/pre>\n<p>\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u306f\u81ea\u52d5\u751f\u6210\u3055\u308c\u305f\u3082\u306e\u3067<br \/>\n\u4e00\u822c\u7684\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5fc5\u8981\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u81ea\u52d5\u3067\u7528\u610f\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>resources\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3068(\u8907\u6570\u5f62\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f)<br \/>\nquestions_controller\u306b\u95a2\u4fc2\u3059\u308b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u81ea\u52d5\u3067\u7528\u610f\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>rails routes\u3067\u78ba\u8a8d<\/p>\n<pre><strong>  Prefix      Verb   URI Pattern       Controller#Action\r\nquestions     GET \/questions(.:format)          questions#index\r\n             POST \/questions(.:format)         questions#create\r\nnew_question  GET \/questions\/new(.:format)      questions#new\r\nedit_question GET \/questions\/:id\/edit(.:format) questions#edit\r\nquestion      GET \/questions\/:id(.:format) questions#show\r\n            PATCH \/questions\/:id(.:format) questions#update\r\n              PUT \/questions\/:id(.:format) questions#update\r\n           DELETE \/questions\/:id(.:format) questions#destroy\r\n\r\nrails_service_blob GET \/rails\/active_storage\/blobs\/:signed_id\/*filename(.:format) active_storage\/blobs#show\r\nrails_blob_representation GET \/rails\/active_storage\/representations\/:signed_blob_id\/:variation_key\/*filename(.:format) active_storage\/representations#show\r\nrails_disk_service GET \/rails\/active_storage\/disk\/:encoded_key\/*filename(.:format) active_storage\/disk#show\r\nupdate_rails_disk_service PUT \/rails\/active_storage\/disk\/:encoded_token(.:format) active_storage\/disk#update\r\nrails_direct_uploads POST \/rails\/active_storage\/direct_uploads(.:format) active_storage\/direct_uploads#create<\/strong><\/pre>\n<p>index:\u00a0 \u00a0 \u00a0\u8cea\u554f\u4e00\u89a7<br \/>\ncreate\uff1a \u8cea\u554f\u306e\u65b0\u898f\u4f5c\u6210\u306e\u3068\u304d\u306e\u51e6\u7406<br \/>\nnew:\u00a0 \u00a0 \u00a0 \u00a0 \u8cea\u554f\u306e\u65b0\u898f\u767b\u9332\u753b\u9762<br \/>\nedit:\u00a0 \u00a0 \u00a0 \u00a0 \u8cea\u554f\u306e\u7de8\u96c6\u753b\u9762<br \/>\nshow:\u00a0 \u00a0 \u00a0 \u8cea\u554f\u8a73\u7d30\u78ba\u8a8d\u753b\u9762<br \/>\nupdate:\u00a0 \u00a0\u8cea\u554f\u306e\u5185\u5bb9\u3092\u66f4\u65b0\u3059\u308b\u3068\u304d\u306e\u51e6\u7406<br \/>\ndestroy:\u00a0 \u8cea\u554f\u306e\u524a\u9664<\/p>\n<p><strong>Prefix<\/strong>\u306f\u30d1\u30b9\u3092\u6307\u5b9a\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>Verb\uff1aHTTP\u30e1\u30bd\u30c3\u30c9\u3068\u304bHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u30e1\u30bd\u30c3\u30c9\u3068\u3082\u547c\u3070\u308c\u307e\u3059\u3002<br \/>\nGet\u3000\u00a0 \u00a0 \u00a0 \u00a0\u30c7\u30fc\u30bf\u306e\u53d6\u5f97 PUT<br \/>\nPOST\u3000\u00a0 \u00a0 \u30c7\u30fc\u30bf\u306e\u9001\u4fe1<br \/>\nDELETE\u3000\u30c7\u30fc\u30bf\u306e\u524a\u9664<br \/>\nURI\u3000Pattern\u3000\u3044\u308f\u3086\u308b\u30a2\u30c9\u30ec\u30b9\u3067\u3059\u3002<\/p>\n<p>questions\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306eindex\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f<br \/>\n\/questions\/index\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308c\u3070\u3088\u3044\u3068\u3044\u3046\u3053\u3068\u3067<br \/>\n\u2191\u306e\u3082\u306e\u306fconfig\u2192routes.rb\u3067\u5909\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>7:root\u30e1\u30bd\u30c3\u30c9\u306e\u8a2d\u5b9a<\/h3>\n<p>\u3053\u308c\u304b\u3089\u3084\u308b\u3053\u3068<br \/>\n\u30eb\u30fc\u30c8URL\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u8cea\u554f\u306e\u4e00\u89a7\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u3044<\/p>\n<pre><strong>config\/routes.rb<\/strong>\u306b\u3066\u8a18\u8ff0\u2193<strong>\r\n  Rails.application.routes.draw do \r\n\r\n    root 'questions#index'\u3000\r\n    resources :questions\r\nend<\/strong><\/pre>\n<p>\u30eb\u30fc\u30c8URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304dquestions\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306eindex\u30a2\u30af\u30b7\u30e7\u30f3\u3092<br \/>\n\u547c\u3076\u8a2d\u5b9a\u3092\u3057\u307e\u3057\u305f\u3002<br \/>\n\u30eb\u30fc\u30c8URL\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u2193\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>Questions#index<br \/>\nFind me in app\/views\/questions\/index.html.erb<\/p>\n<p>rails routes\u3067\u2193\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre><strong>root GET \/ questions#index<\/strong><\/pre>\n<p>\u30eb\u30fc\u30c8URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304dquestions\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306eindex\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u547c\u3076\u8a2d\u5b9a\u3092\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>8\uff1a\u8cea\u554f\u306e\u4e00\u89a7\u30da\u30fc\u30b8\u306e\u4f5c\u6210<\/h3>\n<p><strong>app\/controllers\/questions_controller<\/strong>\u306b\u3066\u8a2d\u5b9a\u2193<\/p>\n<pre><strong>class QuestionsController &lt; ApplicationController\r\n\r\n  def index<\/strong>\r\n #questions\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3059\u3079\u3066\u306e\u8cea\u554f\u3092\u53d6\u5f97\u3059\u308b\r\n  <strong>  @questions = Question.all\r\n  end\r\n\r\n  def show\r\n  end\r\n\r\n  def new\r\n  end\r\n\r\n  def edit\r\n  end<\/strong><\/pre>\n<p><strong>app\/views\/index.html.erb<\/strong>\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u8a18\u8ff0<\/p>\n<pre><strong>&lt;h2&gt;Questions#index&lt;\/h2&gt;\r\n  &lt;div class=\"row\"&gt;\r\n  &lt;div class=\"col-md-12\"&gt;\r\n    &lt;table class=\"table table-striped\"&gt;\r\n     &lt;thead class=\"thead-light\"&gt;\r\n       &lt;tr&gt;\r\n        &lt;th&gt;ID&lt;\/th&gt;\r\n        &lt;th&gt;Title&lt;\/th&gt;\r\n        &lt;th&gt;Menu&lt;\/th&gt;\r\n       &lt;\/tr&gt;\r\n     &lt;\/thead&gt;\r\n    &lt;\/table&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;<\/strong><\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u304b\u3089\/questions\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u308c\u3070OK<\/p>\n<p><strong>Questions#index<\/strong><br \/>\n<strong>ID Title Menu<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2795\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/41aed981b325ed920be1d8ce4465a6e2.png\" alt=\"\" width=\"828\" height=\"614\" srcset=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/41aed981b325ed920be1d8ce4465a6e2.png 828w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/41aed981b325ed920be1d8ce4465a6e2-300x222.png 300w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/41aed981b325ed920be1d8ce4465a6e2-768x570.png 768w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/41aed981b325ed920be1d8ce4465a6e2-624x463.png 624w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/p>\n<p>\u66f4\u306b\u6b21\u306e\u3088\u3046\u306b\u8a18\u8ff0<\/p>\n<pre><strong>&lt;h2&gt;Questions#index&lt;\/h2&gt;\r\n  &lt;div class=\"row\"&gt;\r\n  &lt;div class=\"col-md-12\"&gt;\r\n    &lt;table class=\"table table-striped\"&gt;\r\n     &lt;thead class=\"thead-light\"&gt;\r\n      &lt;tr&gt;\r\n       &lt;th&gt;ID&lt;\/th&gt;\r\n       &lt;th&gt;Title&lt;\/th&gt;\r\n       &lt;th&gt;Menu&lt;\/th&gt;\r\n      &lt;\/tr&gt;\r\n     &lt;\/thead&gt;\r\n   &lt;tbody&gt;\r\n    &lt;% @questions.each do |question| %&gt;\r\n     &lt;tr&gt;\r\n      &lt;td&gt;&lt;%= question.id %&gt;&lt;\/td&gt;\r\n      &lt;td&gt;&lt;%= question.title %&gt;&lt;\/td&gt;\r\n      &lt;td&gt;[edit] [Delete]&lt;\/td&gt;\r\n     &lt;\/tr&gt;\r\n    &lt;% end %&gt;\r\n   &lt;\/tbody&gt;\r\n  &lt;\/table&gt;\r\n&lt;\/div&gt;<\/strong><\/pre>\n<p><strong>app\/controllers\/questions_controller<\/strong>\u306b\u3066<br \/>\n@questions = Question.all<br \/>\nQuestion\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5168\u3066\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3057\u3066<br \/>\n@questions\u306b\u4ee3\u5165\u3057\u3066<br \/>\n<strong>app\/views\/questions\/index.html.erb<\/strong>\u306e\u4e2d\u3067\u4f7f\u308f\u308c\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u8907\u6570\u5165\u3063\u3066\u3044\u308bquestion\u306e\u30c7\u30fc\u30bf\u3092each\u3067\u4e00\u3064\u305a\u3064\u53d6\u308a\u51fa\u3057\u3066\u3001<br \/>\nquestion,id\u3084\u30bf\u30a4\u30c8\u30eb\u3092\u8cea\u554f\u56de\u6570\u5206\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>9:\u30b7\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u305f\u521d\u671f\u30c7\u30fc\u30bf\u306e\u6295\u5165<\/h3>\n<p>\u8cea\u554f\u3092\u6295\u7a3f\u3059\u308b\u6a5f\u80fd\u304c\u672a\u5b9f\u88c5\u3067\u3001<br \/>\n\u4e00\u89a7\u753b\u9762\u30c7\u30fc\u30bf\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3068\u3053\u308d\u306e\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u306a\u3044\u306e\u3067<br \/>\n\u521d\u671f\u30c7\u30fc\u30bf\u3092\u4f5c\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u633f\u5165\u3001<br \/>\n\u30b7\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u305f\u521d\u671f\u30c7\u30fc\u30bf\u306e\u6295\u5165\u3059\u308b\u6a5f\u80fd\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>db\/seeds.rb\u3067\u2193\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u3066\u521d\u671f\u30c7\u30fc\u30bf\u306e\u6295\u5165\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>Question.create(id: 1, name: 'test name 1', title: 'Test question 1', content: 'Test content 1')<\/strong>\r\n<strong>Question.create(id: 2, name: 'test name 2', title: 'Test question 2', content: 'Test content 2')<\/strong>\r\n<strong>Question.create(id: 3, name: 'test name 3', title: 'Test question 3', content: 'Test content 3')<\/strong><\/pre>\n<p>Question.create\u30673\u30ec\u30b3\u30fc\u30c9\u5206\u306e\u30c7\u30fc\u30bf\u3092\u4f5c\u308a<\/p>\n<pre>\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u30b3\u30de\u30f3\u30c9\r\nrails db:seed<\/pre>\n<p>\u4f55\u3082\u8868\u793a\u3055\u308c\u306a\u3051\u308c\u3070OK<\/p>\n<p>\u30eb\u30fc\u30c8URL\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u2193\u306e\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u308c\u3070OK<\/p>\n<pre><strong>Questions#index<\/strong>\r\n<strong>ID Title Menu<\/strong>\r\n<strong>1 Test question 1 [edit] [Delete]<\/strong>\r\n<strong>2 Test question 2 [edit] [Delete]<\/strong>\r\n<strong>3 Test question 3 [edit] [Delete]<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2797\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa.png\" alt=\"\" width=\"1424\" height=\"568\" srcset=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa.png 1424w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa-300x120.png 300w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa-1024x408.png 1024w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa-768x306.png 768w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/35ef65c51be3114f0be813ef700c41aa-624x249.png 624w\" sizes=\"auto, (max-width: 1424px) 100vw, 1424px\" \/><\/p>\n<h3>10:Bootstrap\u3092\u5c0e\u5165\u3059\u308b(\u30d5\u30ed\u30f3\u30c8\u306e\u90e8\u5206\u3092\u52b9\u7387\u826f\u304f\u4f7f\u3046)<\/h3>\n<p><strong>Gemfile<\/strong>\u306b\u3066\u4e00\u756a\u4e0b\u306b\u6b21\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>gem 'bootstrap', '~&gt; 4.1.1'<\/strong>\r\n<strong>gem 'jquery-rails', '~&gt; 4.3.1'<\/strong><\/pre>\n<pre>\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u3066<strong>bundle install<\/strong>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u3057\u3066\u30ea\u30cd\u30fc\u30e0(\u62e1\u5f35\u5b50css\u3092scss)\u306b\u5909\u66f4\r\n\r\n<strong>mv app\/assets\/stylesheets\/\/application.css app\/assets\/stylesheets\/application.scss<\/strong><\/pre>\n<p>scss\u306f\u30b5\u30b9\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3067CSS\u3092\u4fbf\u5229\u306b\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3059\u3002<br \/>\n\u539f\u5247css\u3092\u8a18\u8ff0\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3067\u4f7f\u308f\u308c\u308b\u30b9\u30bf\u30a4\u30eb\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u30d5\u30a1\u30a4\u30eb<\/p>\n<p><strong>app\/assets\/stylesheets\/application.scss<\/strong>\u3092\u958b\u304d\u8a18\u8ff0<\/p>\n<pre>bootstrap\u3092\u8aad\u307f\u8fbc\u3080\u8a2d\u5b9a\r\n<strong>@import \"bootstrap\";<\/strong><\/pre>\n<p><strong>app\/assets\/javascripts\/application.js<\/strong>\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u8a18\u8ff0<\/p>\n<pre>\/\/ This is a manifest file that'll be compiled into application.js, which will include all the files\r\n\/\/ listed below.\r\n\/\/\r\n\/\/ Any JavaScript\/Coffee file within this directory, lib\/assets\/javascripts, or any plugin's\r\n\/\/ vendor\/assets\/javascripts directory can be referenced here using a relative path.\r\n\/\/\r\n\/\/ It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the\r\n\/\/ compiled file. JavaScript code in this file should be added after the last require_* statement.\r\n\/\/\r\n\/\/ Read Sprockets README (https:\/\/github.com\/rails\/sprockets#sprockets-directives) for details\r\n\/\/ about supported directives.\r\n\/\/\r\n<strong>\/\/= require rails-ujs<\/strong>\r\n<strong>\/\/= require activestorage<\/strong>\r\n<strong>\/\/= require turbolinks<\/strong>\r\n<strong>\/\/= require jquery3<\/strong>\r\n<strong>\/\/= require popper<\/strong>\r\n<strong>\/\/= require bootstrap-sprockets<\/strong>\r\n<strong>\/\/= require_tree .<\/strong><\/pre>\n<p>\u30bb\u30fc\u30d6\u3057\u3066\u30eb\u30fc\u30c8URL\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u30b9\u30bf\u30a4\u30eb\u304c\u5f53\u305f\u3063\u3066\u3044\u308c\u3070OK\u3067\u3059\u3002<br \/>\n\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u4e2d\u592e\u63c3\u3048\u306b\u3057\u305f\u3044\u306e\u3067<br \/>\n<strong>app\/views\/layouts\/application.html.erb<\/strong>\u306b\u3066\u2193\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;!DOCTYPE html&gt;<\/strong>\r\n<strong>&lt;html&gt;<\/strong>\r\n<strong>&lt;head&gt;<\/strong>\r\n<strong>  &lt;title&gt;Qanda&lt;\/title&gt;<\/strong>\r\n<strong>    &lt;%= csrf_meta_tags %&gt;<\/strong>\r\n<strong>    &lt;%= csp_meta_tag %&gt;<\/strong>\r\n<strong>  &lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&gt;<\/strong>\r\n<strong>  &lt;%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %&gt;<\/strong>\r\n<strong>&lt;\/head&gt;<\/strong>\r\n<strong>&lt;body&gt;<\/strong>\r\n<strong>  &lt;div class=\"container\"&gt;<\/strong>\r\n<strong>    &lt;%= yield %&gt;<\/strong>\r\n<strong>  &lt;\/div&gt;<\/strong>\r\n<strong> &lt;\/body&gt;<\/strong>\r\n<strong>&lt;\/html&gt;<\/strong><\/pre>\n<p>yield\u306findex.html.erb\u306a\u3069\u306e\u5404\u30da\u30fc\u30b8\u3054\u3068\u306b\u7570\u306a\u308b\u5b9f\u88c5\u304c\u547c\u3073\u51fa\u3055\u308c\u3066\u3001\u57cb\u3081\u8fbc\u307e\u308c\u308b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2799\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821.png\" alt=\"\" width=\"1718\" height=\"814\" srcset=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821.png 1718w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821-300x142.png 300w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821-1024x485.png 1024w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821-768x364.png 768w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821-1536x728.png 1536w, https:\/\/suzutukiblog.com\/wp-content\/uploads\/2021\/04\/1503d50e5ffb75b3ad3c139f8acdf821-624x296.png 624w\" sizes=\"auto, (max-width: 1718px) 100vw, 1718px\" \/><br \/>\n\u4e0a\u306e\u3088\u3046\u306b\u4e2d\u592e\u63c3\u3048\u306b\u306a\u3063\u305f\u306e\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<br \/>\n\u30da\u30fc\u30b8\u306e\u30bd\u30fc\u30b9\u3092\u8868\u793a\u304b\u3089&lt;h2&gt;\u30bf\u30b0\u304b\u3089<\/p>\n<pre><strong>&lt;h2&gt;Questions#index&lt;\/h2&gt;<\/strong>\r\n<strong>  &lt;div class=\"row\"&gt;<\/strong>\r\n<strong>  &lt;div class=\"col-md-12\"&gt;<\/strong>\r\n<strong>    &lt;table class=\"table table-striped\"&gt;<\/strong>\r\n<strong>      &lt;thead class=\"thead-light\"&gt;<\/strong>\r\n<strong>     &lt;tr&gt;<\/strong>\r\n<strong>      &lt;th&gt;ID&lt;\/th&gt;<\/strong>\r\n<strong>      &lt;th&gt;Title&lt;\/th&gt;<\/strong>\r\n<strong>      &lt;th&gt;Menu&lt;\/th&gt;<\/strong>\r\n<strong>     &lt;\/tr&gt;<\/strong>\r\n<strong>      &lt;\/thead&gt;<\/strong>\r\n<strong>    &lt;tbody&gt;<\/strong>\r\n<strong>     &lt;tr&gt;<\/strong>\r\n<strong>      &lt;td&gt;1&lt;\/td&gt;<\/strong>\r\n<strong>       &lt;td&gt;Test question 1&lt;\/td&gt;<\/strong>\r\n<strong>       &lt;td&gt;[edit] [Delete]&lt;\/td&gt;<\/strong>\r\n<strong>      &lt;\/tr&gt;<\/strong>\r\n<strong>     &lt;tr&gt;<\/strong>\r\n<strong>      &lt;td&gt;2&lt;\/td&gt;<\/strong>\r\n<strong>       &lt;td&gt;Test question 2&lt;\/td&gt;<\/strong>\r\n<strong>       &lt;td&gt;[edit] [Delete]&lt;\/td&gt;<\/strong>\r\n<strong>     &lt;\/tr&gt;<\/strong>\r\n<strong>     &lt;tr&gt;<\/strong>\r\n<strong>      &lt;td&gt;3&lt;\/td&gt;<\/strong>\r\n<strong>      &lt;td&gt;Test question 3&lt;\/td&gt;<\/strong>\r\n<strong>      &lt;td&gt;[edit] [Delete]&lt;\/td&gt;<\/strong>\r\n<strong>     &lt;\/tr&gt;<\/strong>\r\n<strong>    &lt;\/tbody&gt;<\/strong>\r\n<strong>   &lt;\/table&gt;<\/strong>\r\n<strong> &lt;\/div&gt;<\/strong>\r\n<strong>&lt;\/div&gt;<\/strong><\/pre>\n<p>\u3053\u3053\u307e\u3067\u306f<strong>app\/views\/questions\/index.html.erb<\/strong>\u3067\u66f8\u304b\u308c\u305f\u90e8\u5206<br \/>\n\u4ed6\u306e\u90e8\u5206\u306f<strong>app\/views\/layouts\/application.html.erb<\/strong>\u3067\u66f8\u304b\u308c\u305f\u90e8\u5206\u3067\u3053\u306e2\u3064\u304c\u5408\u308f\u3055\u3063\u3066\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<p><a href=\"https:\/\/suzutukiblog.com\/index.php\/2021\/04\/13\/rails-8\/\">\u305d\u306e4\u306b\u7d9a\u304d\u307e\u3059<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305d\u306e2\u304b\u3089\u7d9a\u304f \u30df\u30cbQ&amp;A\u30a2\u30d7\u30ea\u3092\u4f5c\u308d\u3046\uff01 \u958b\u767a\u74b0\u5883\u306fCloud9\u3067\u884c\u3046 0:\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3092\u3057\u307e\u3059\u3002 sudo yum update Ruby\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d rvm -v rvm install  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2764,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27,13],"tags":[],"class_list":["post-2774","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-note","category-rails"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=2774"}],"version-history":[{"count":17,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2774\/revisions"}],"predecessor-version":[{"id":4487,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2774\/revisions\/4487"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media\/2764"}],"wp:attachment":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=2774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=2774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=2774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}