0
full_name
で空でない場合は、first_name
とlast_name
を連結し、honorific_prefix
を追加するにはどうすればよいですか?私はちょうどif
と<>
を使用したいビュー内の文字列を連結
defmodule MyApp.UserView do
use MyApp.Web, :view
alias MyApp.User
def full_name(%User{first_name: first_name,
last_name: last_name,
honorific_prefix: honorific_prefix}) do
first_name
|> String.upcase
end
end