I am new to the Rails framework and Ruby language in general but I do have some programming and MVC experience. I am trying to output a link using rails’ link_to method. However in the HTML this link is inside another set of double quotes. I need to escape the quotes produced by rails in the tag.
I have tried google and only found information for javascript escaping which didnt help. I tried using a h(%[]) method that was mentioned a few times but then the link was not created and the actual words link_to were out put.
Does anyone know how I can escape the double quotes in the hyperlink tag created by rails or switch it to use a single quote?
Actual Code
<% @properties = Property.all
@properties.each do |property| %>
<img src="images/img<%= property.id %>.jpg" alt="" title="<strong><%= property.address %></strong><span>9 rooms, 3 baths, 6 beds, building size: 5000 sq. ft. Price: $ 600 000 <%= link_to "Read More", property) %></span>">
<% end %>
Output
<img src="images/img1.jpg" alt="" title="<strong>50 Craft LAne</strong><span>9 rooms, 3 baths, 6 beds, building size: 5000 sq. ft. Price: $ 600 000 <a href="/properties/1">Read More</a></span>">
The first double quote in the hyperlink is pairing with the title=” and then everything is off
You can do something like that: