<a href="/patients/#{@appointment.patient.id}">
<%=h @appointment.patient.f_name %> <%=h @appointment.patient.l_name%>
</a>
但由于语法错误而无法正常工作,如果我点击href它会转到http://0.0.0.0:3000/patients/#{@appointment.patient.id}
感谢
答案 0 :(得分:13)
你可以这样做:
<a href="/patients/<%= @appointment.patient.id %>">
但使用link_to
通常更容易:
link_to(@appointment.patient.f_name + " " + @appointment.patient.l_name,
:controller => 'patients', :action => 'show', :id => @appointment.patient.id)