Reputation: 6105
I have 2 methods like this in my user_helper.rb
def full_name(user)
if user.last_name?
user.first_name + " " + user.last_name
else
user.first_name
end
end
def user_info(user)
full_name(user)
user.city
end
And in the view
<%= user_info(current_user) %>
It renders well the city, but not the full_name I've tried with html_safe also but It doesn't work. COul you explain me why?
Thank you!
Upvotes: 1
Views: 102
Reputation: 20599
Well, the implicit function return only covers the user.city
part, you'd have to concatenate the two strings if you want to display them both.
def user_info(user)
full_name(user) + ' ' + user.city
end
Upvotes: 3