【发布时间】:2017-04-03 20:46:09
【问题描述】:
我正在使用 ruby on rails 在 postgres db 上写一篇博文。表中帖子的内容有一些外部链接。我一直在使用 link_to 方法,但到目前为止,这只是在浏览器中从 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 %>
但这些变化似乎都不起作用......
我的 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-->
【问题讨论】:
标签: ruby-on-rails postgresql erb link-to