#10 Refactoring User Name Part 1

#show.rhtml
Name: <%= @user.full_name %>


#models/user.rb
def full_name
  name = first_name + " "
  name += "#{middle_initial}. " unless middle_initial.nil?
  name += last_name
  name
end

你可能感兴趣的:(Ruby,Rails)