current_userでログイン中のユーザ名とメールアドレスの表示の仕方を紹介します。
書き始めるときはcurrent_user
の前に=
を忘れないでくださいね!
###ユーザー名を表示 〜current_user〜
.header__left-box__list
= current_user.user

メールアドレスを表示させたい↓
.header__left-box__list
= current_user.email #nameからemailに変更

なぜ、このように
= current_user.name
や= current_user.email
のようになるかというと、、、テーブルに注目。
↓
###○usersテーブル
id | name |
email |
---|---|---|
1 | mirai | mirai@mirai.com |
2 | : | : |
3 | : | : |
name
カラムやemail
カラムから引っ張ってきているのです!
=current_user
の後ろには.
を忘れず書く事!!
また、each doも同じです。
ではまた(^_^ )
おまけ
###ユーザー名を表示 〜each do〜
.header__left-box__list
- @group.users.each do |hhgg|
= hhgg.name

メールアドレスを表示させたい↓
.header__left-box__list
- @group.users.each do |hhgg|
= hhgg.email #nameからemailに変更
