Skip to content

Commit

Permalink
added name method in User model that returns full name
Browse files Browse the repository at this point in the history
  • Loading branch information
zluo16 committed Jun 23, 2017
1 parent 4b0759f commit e15e16f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class User < ApplicationRecord
validates :email, presence: true
validates :first_name, presence: true

def name
"#{first_name} #{last_name}"
end

def link_to_image
"https://lh3.googleusercontent.com/H9yAIsZYqbIOh_E1ON90chVhO6SYSD6ucV-XirZXkMFDqLRjGoztobaxx1XS9CB4lfg=w300"
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<% end %>
</div>
<div>
<h3> <%= @user.first_name %></h3>
<h3> <%= @user.name %></h3>
</div>


Expand Down

0 comments on commit e15e16f

Please sign in to comment.