0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【アウトプット メモ】

Posted at

rails g controller posts index
でコントローラとアクションを生成する。
posts controller.erb
index.html.erb
を作られる。

<%= posts.each do |post| %>
このeachはpostsに入っているデータをpostに代入して1つずつ取り出す
*postは変数

rails g model Post content :text
Postはモデル名
contentはカラム名
textはデータ型

実行するとこんなのが作られる
model/post.rb

db/migrate/202011..._create_posts.rb
*postsはPostの複数形なぜかこうなる 多分そういう仕様
中身(202011..._create_posts.rb)

class CreatePosts < ActiveRecord::Migration[5.0]
def change
create_table :posts do |t|
t.text :content
t.timestamps
end
end
end

中途半端だけどここまで

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?