I have the following code which I need to update…
<% @users.each do |user| %>
<tr>
<td><%= link_to user.fname, user %></td>
</tr>
<% end %>
I want to learn how to update that so instead of just showing the fname, it shows fname + lname
so for a record like James Bond, it shows james bond and links it to the user in Rails.
thanks
You can join the string right in the ERB:
Or, you can move that ugly logic into a helper method, e.g. in app/helpers/users_helper.rb:
Or, (this is what I would do) you can put a full_name method in the model: