Ruby on rails 轨道连接到DONS';不接受ruby代码内部

Ruby on rails 轨道连接到DONS';不接受ruby代码内部,ruby-on-rails,Ruby On Rails,我的Rails应用程序有问题。我想链接 <h1><%= news.title %></h1> 像这样。但是我想使用link_来代替HTML标记“a” <a href="trainers-single.html" class="postTitle"><h1><%= news.title %></h1></a> 比如: “postTitle”%> 但它不接受。正确的显示方式是什么?只需使用

我的Rails应用程序有问题。我想链接

<h1><%= news.title %></h1> 

像这样。但是我想使用link_来代替HTML标记“a”

<a href="trainers-single.html" class="postTitle"><h1><%= news.title %></h1></a>

比如:

“postTitle”%>
但它不接受。正确的显示方式是什么?

只需使用:

<h1><%= link_to news.title, news, :class => "postTitle" %></h1>
“postTitle”%>
只需使用:

<h1><%= link_to news.title, news, :class => "postTitle" %></h1>
“postTitle”%>
“postTitle”do%> 我想你也可以用

<%= link_to "<h1>#{ news.title }</h1>".html_safe, news, :class => "postTitle" %>
“postTitle”%>
“postTitle”do%> 我想你也可以用

<%= link_to "<h1>#{ news.title }</h1>".html_safe, news, :class => "postTitle" %>
“postTitle”%>

要在
h1
标记外获取
a
标记,请执行以下操作:

<%= 
link_to news, class: "postTitle" do
%>
  <h1><%= news.title %></h1>
<%
end
%>

要在
h1
标记外获取
a
标记,请执行以下操作:

<%= 
link_to news, class: "postTitle" do
%>
  <h1><%= news.title %></h1>
<%
end
%>


此解决方案不提供到h1的链接,而是创建一个具有链接的h1链接。类似:此解决方案不提供到h1的链接,而是创建具有链接的h1链接。比如:代替