hirolibe / hiro-blogapp

0 stars 0 forks source link

気づき(author_name) #21

Open hirolibe opened 3 months ago

hirolibe commented 3 months ago

app/models/article.rbファイルで下記のように表現可能 ArticleモデルでUserモデル内のデータを取得可能

def author_name
  user.email.split('@').first
end
hirolibe commented 3 months ago

プロフィール作成時に app/views/profiles/show.html.hamlにて下記のように表現するため、 .email.split('@').firstをdisplay_nameメソッドとして残しておいたほうがよい

current_user.display_name