安装和使用
#gemfile
gem 'record_tag_helper', '~> 1.0'
#div_for在view中的使用
<%= div_for comment do %>
#comment是已经被定义的变量
...
<% end %>
#controller中跳转到相应的评论内容
redirect_to article_path(@article, anchor: "comment_#{@comment.id}")
#application.scss
.comment {
border-top: 1px solid #ccc;
padding: 8px 0px;
&:target {
background-color: rgb(248, 238, 199);
padding: 8px;
}
}