我的代码如下
<%= div_for(comment) do %>
<div class="comments_wrapper clearfix">
<div class="pull-left">
<p class="lead"><%= comment.body %></p>
<p><small>Submitted <strong><%= time_ago_in_words(comment.created_at) %> ago</strong> by <%= comment.user.name %></small></p>
</div>
Run Code Online (Sandbox Code Playgroud)
我使用的是 Rails v5.0、Ruby 2.3.1 版本。当我使用“rails s”命令运行应用程序时。
它抛出以下错误。
错误:RecordTagHelper。
可能是什么原因?
最后我找到了答案。
\n我们都知道rails5最近发布了。
旧版本 Rails<5.0 中操作视图中的代码已被删除。
\n\n所以我们需要添加一个名为 \xe2\x80\x98record_tag_helper\xe2\x80\x99 的 gem
\n\n就我而言
\n我的查看代码如下
<%= div_for(comment) do %>\n<div class="comments_wrapper clearfix">\n <div class="pull-left">\n <p class="lead"><%= comment.body %></p>\n <p><small>Submitted <strong><%= time_ago_in_words(comment.created_at) %> ago</strong> by <%= comment.user.name %></small></p>\n </div>\nRun Code Online (Sandbox Code Playgroud)\n\n当我在新版本的 Rails 中运行应用程序时,它无法工作
\n\n为什么它不工作?
\n\nRecordTagHelper 由以前属于\n“ActionView”的代码组成。
\n但已从 Rails 5 的核心中删除。
解决方案
\n\n我们需要将 gem \xe2\x80\x98record_tag_helper\xe2\x80\x99, \xe2\x80\x98~> 1.0\xe2\x80\x99 添加到我们的 gem 文件中并运行捆绑安装。
\n\n提供此 gem 是为了确保使用 ActionView::Helpers::RecordTagHelper\n功能的项目具有适当的升级路径。
\n| 归档时间: |
|
| 查看次数: |
1645 次 |
| 最近记录: |