Rails - Problem rendering an helper method in another helper method in a view
I have 2 methods like this in my user_helper.rb
def full_name(user)
if user.last_name?
u开发者_JAVA技巧ser.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!
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
精彩评论