2

Ideally I want some like this LastName, FirstName, how to put comma into the link ?

<%= link_to @name.first.LastName,@name.first.FirstName, management_show_path(:user_id => @name.first.id) %>
4

3 回答 3

4
<%= link_to @name.first.LastName+ ','+ @name.first.FirstName, management_show_path(:user_id => @name.first.id) %>
于 2013-08-05T20:11:11.583 回答
3

Like this:

<%= link_to "#{@name.first.LastName}, #{@name.first.FirstName}", management_show_path(:user_id => @name.first.id) %>
于 2013-08-05T20:13:23.010 回答
1

I'd use a helper method. Something like:

def user_name(user)
  [user.last_name, user.first_name].join ", "
end

and call it via:

<%= link_to user_name(@user), management_show_path(user_id: @user.id) %>
于 2013-08-05T20:34:25.113 回答