Je suis en train d'écrire un article de blog sur un postgres db utilisant ruby on rails. Le contenu de la publication dans la table a des liens externes. J'ai utilisé la méthode link_to, mais jusqu'ici cela a juste imprimé le code exact dans le navigateur du fichier html.erb. Jusqu'à présent, je l'ai essayé:Comment link_to du contenu de la base de données dans une page html.erb
<%= link_to 'London Coffee Festival', http://www.londoncoffestival.com %>
<% link_to 'London Coffee Festival', http://www.londoncoffestival.com %>
<%= link_to 'http://www.londoncoffestival.com'do %>London Coffee Festival<% end %>
Mais pas de ces variations semblent fonctionner ...
ma page html.erb:
<%= render "partials/mainnav" %>
<div class="ui fluid image"><%= image_tag "header_img_thin.jpg" %>
</div>
<div class="ui grid container"><!--Main page container-->
<div class="row">
<div class="twelve wide column"><!--left Column-->
<h1><%= @article.title %></h1>
<p><%= @article.text %></p>
<h2>Comments</h2>
<% @article.comments.each do |comment| %>
<p><strong>Name</strong>
<%= comment.commenter %>
</p>
<p>
<strong>Comment:</strong>
<%= comment.body %>
</p>
<% end %>
<h2>Add a comment:</h2>
<%= form_for([@article, @article.comments.build]) do |f| %>
<p>
<%= f.label :Name %><br>
<%= f.text_field :commenter %>
</p>
<p>
<%= f.label :Comment %><br>
<%= f.text_area :body %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<%= link_to 'Back', articles_path %>
</div><!--end left column-->
<div class="four wide column"><!--right column-->
<p>
Text
</p>
</div><!--end right column-->
</div>
</div><!--End of main page container-->
Malheureusement non. Ce qui n'a pas de sens. –
@SimonCooper êtes-vous sûr d'utiliser 'erb'? Parce que je viens de copier collé exactement le même code ci-dessus et cela fonctionne –
Oui, def, le nom de fichier est 'app/views/articles/show.html.erb'. J'essaye seulement ceci sur l'hôte local. Impossible de publier en production maintenant. –