<%=h @appointment.patient.f...">

How can I insert a variable in href value in a link in rails?

I have:

<a href="/patients/#{@appointment.patient.id}"> <%=h @appointment.patient.f_name %> <%=h @appointment.patient.l_name%> </a> 

but the dose does not work due to a syntax error, if I click on href, it goes to http://0.0.0.0:3000/patients/#{@appointment.patient.id}

thanks

+4
source share
1 answer

You can do:

 <a href="/patients/<%= @appointment.patient.id %>"> 

But it's usually easier to use link_to :

 link_to(@appointment.patient.f_name + " " + @appointment.patient.l_name, :controller => 'patients', :action => 'show', :id => @appointment.patient.id) 
+14
source

All Articles