rails link_to 带有动作参数的正文?

rails link_to body with action parameter?

我有一篇文章 table 和一条回复 table。 包含专栏 'reply_count' 的文章。在视图中,我想在我的 link_to 中显示回复计数,但我不知道该怎么做。

这是控制器代码

class ArticleController < ApplicationController

  def index
    @article = Article.all
  end

end

这里是文章视图

<%= link_to 'Reply(<%= article.replies_count %>)', path %>

希望能这样显示

<a href=path> Reply(2) </a>

需要大家的帮助,谢谢...

字符串插值是关键字。请注意双引号,它会使 #{} 起作用

<%= link_to "Reply #{article.replies_count}", path %>