I'd like to have embededd ruby code as my link name. Right now I tried to implement it like this:
<% @user.each do |user| %>
<li><%= link_to '<%= user.familyname %>, <%= user.forename %> ', user %> </li>
<% end %>
But it's not working, Rails gives me a syntax error:
syntax error, unexpected $undefined, expecting ')'
...);@output_buffer.safe_concat('\', user %> </li>
... ^
What do I need to change in the syntax, 开发者_StackOverflow社区so this Link will work?
you can not do <%= %> inside an <%= %>. you can try something like this:
<% @users.each do |employee| %>
<li><%= link_to "#{employee.familyname}, #{employee.forename}", employee %> </li>
<% end %>
Just simple
<%= link_to [user.familyname, user.forename].join(','), user_path %>
精彩评论