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
1_table_set #1
base: main
Are you sure you want to change the base?
1_table_set #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしましたー。
ファイルの拡張子は.md
の方が良いですよ。マークダウンが使えるので。
また、
* users
・nickname:string
じゃなく
* users
* nickname: string
にしましょう。
何がどう違うのかは考えてみてください。
table_set.txt
Outdated
@@ -0,0 +1,34 @@ | |||
* users | |||
・nickname:string | |||
・avatar_image_id:string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これは何でしょう?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以前作ったrailsのアプリで画像の登録を実像する際、gemのgem "refile" と "refile-mini_magick"を使ったことがあるのですが、そのときにimage_id: string のような書き方で実装できたいたので、このような書き方をしました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどー。これはActiveStorageを使った方が楽だと思いますよ。
ちなみに課題図書の現場で使えるRuby on Rails 5速習実践ガイドって読みました?
https://tech-essentials.work/courses/7
課題内容
Rubyのフレームワークである『Rails』の基本から応用までを学びましょう。
書籍『現場で使える Ruby on Rails 5速習実践ガイド』を読み、学んだことをアウトプットしてください。
現場で使える Ruby on Rails 5速習実践ガイド
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すいません。まだ購入してなかったので、月曜日届いたら読みます。
そして、届いたのですが、結構時間がかかるので、やりながらこちらも取り組んでいきます!
table_set.txt
Outdated
・avatar_image_id:string | ||
・email:string | ||
・password:string | ||
・hostman:boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これはなんでしょう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
管理者か一般ユーザーを見分けるためのカラムにするつもりでした。
デフォルト値を設定して、一般ユーザーはいじれないようにしとけば管理者を判断できるかなと思いました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど。hostmanという命名は聞いたことないのであまり一般的ではないと思います。admin
でどうでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admin(管理者)に変えます!
table_set.txt
Outdated
* questions | ||
・user_id:integer | ||
・title:string | ||
・text:body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body:textですかね。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以前作ったrailsのスキーマーを見ながら作っていたので、間違えました・・・
直します!
table_set.txt
Outdated
* answers | ||
・user_id:integer | ||
・question_id:integer | ||
・comment:body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment:bodyとはなんでしょう?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本当はanswerにしたかったのですが、テーブル名と被ると以前エラーでた記憶があってこのような書き方をしました。回答の中身を入れるカラムのつもりです。bodyは間違いです。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テーブル名と被ると以前エラーでた記憶があって
これは勘違いだと思います。
とはいえanswer.answer
のように参照するのは違和感あるのでbody
カラムにしたほうが良いかと思いました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bodyに変えます。テーブル名勉強します。
table_set.txt
Outdated
・created_at:datetime | ||
・updated_at:datetime | ||
|
||
* solutions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これは何のためのテーブルでしょう?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解決したか、してないかを実装するテーブルのつもりでした。
いいね機能のテーブルがこんな感じだったので参考にしました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いいね機能のテーブルがこんな感じだったので参考にしました。
どこをどう参考にしましたか?根拠を教えていただければなと思います!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いいねのon,off と 解決した、解決していないボタン で2パターンの動きなので、近いかなーと思いました。
すいません。いいね機能も完全に理解して、実装したわけではなかったので、はっきり答えられません。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こういう理解が曖昧なところをメンターに質問してほしいなぁと思います。
どうしても課題を進めることが目的になっちゃってる感じがします。
質問してもらえれば考え方のヒントを答えるので理解が曖昧なところはそのままにしないで質問してほしいです...!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます!質問します!
この解決したボタンについては、questions のテーブルに 解決したか、してないかを判断するカラムさえあればいい、と思いました。
table_set.txt
Outdated
|
||
* solutions | ||
・user_id:integer | ||
・questions_id:integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
単数, 複数どちらが正しいでしょうか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解決に数はないので単数です。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「rails テーブル名 ルール」とかで調べてみましょう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
調べます。
モデル名は単数形、テーブル名は、スネークケースの複数形です。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
もう修正されているので把握されていると思いますけど、ここでだいそんさんが質問しているのは「questions_id」のことだと思いますよ!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全然気づいてませんでした。みけたさん、ありがとうございます!
questions_id ではなく question_id でした。
idは一つのquestion と紐付いてるので、s はいらなかったです。
あってますでしょうか!?><
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idは一つのquestion と紐付いてるので、s はいらなかったです。
確かにそれはそうなんですが、Railsのルールとして覚えておきましょう。
https://railsguides.jp/active_record_basics.html#%E5%91%BD%E5%90%8D%E3%83%AB%E3%83%BC%E3%83%AB
https://railsguides.jp/active_record_basics.html#%E3%82%B9%E3%82%AD%E3%83%BC%E3%83%9E%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%AB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい!覚えます!
table_set.md
Outdated
@@ -3,31 +3,45 @@ | |||
* avatar_image_id: string | |||
* email: string | |||
* password: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テーブル設計とは関係ない部分ですが、セキュリティの観点から、実際に保存するのはパスワード自体でなく、パスワードを暗号化したものにするのが定石というのをおさえておくといいと思います!
https://qiita.com/ryosuketter/items/805452b7e6bf9637cb57
https://railstutorial.jp/chapters/modeling-users?version=4.0#sec-an_encrypted_password
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます。抑えます!。。ちなみに、
gem devise を使うと、アクセストークンなどのpsに関わりそうなカラムができるのですが関係あるのでしょうか!?
アクセストークンっていうのは別の話ですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
まず「アクセストークンとは」でググってみましょう 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
アクセストークンは別の話でした。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
検索機能と管理者機能がこのテーブルでできるのか、定かではないのですが、1度チェックお願いします!