Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コメント用のテーブルを作る #77

Merged
merged 4 commits into from
Sep 6, 2016
Merged

Conversation

yucao24hours
Copy link
Member

やったこと

Post に対する Comment を格納するためのテーブルを作るマイグレーションを作成しました。

実際にコメントを作成・表示するところは #64 でやるので、こちらを先にマージする必要があります。

対応する issue

connects to #35

class CreateComments < ActiveRecord::Migration[5.0]
def change
create_table :comments do |t|
t.integer :commented_by_id, null: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

外部キーには外部キー制約とインデックスつけていいと思います


rename_column :comments, :user_id, :commented_by_id

add_foreign_key :comments, :users, column: 'commented_by_id'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@5t111111
Copy link
Collaborator

5t111111 commented Sep 6, 2016

LGTM

@5t111111 5t111111 merged commit f488f96 into master Sep 6, 2016
@5t111111 5t111111 deleted the create-comments-table branch September 6, 2016 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants