【发布时间】:2018-08-04 13:17:16
【问题描述】:
尝试运行我的 Rails 应用时出错。我认为这可能是基于我在 Stack Overflow 中研究的类似错误的数据问题。下面是命令行的输出:
ActionView::Template::Error ('nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.):
2: <% provide(:blog_active, 'active') %>
3:
4: <div class="row">
5: <%= render @posts %>
6: </div>
app/views/blog/posts/index.html.erb:5:in `_app_views_blog_posts_index_html_erb__817338750_58788108'
【问题讨论】:
-
您可以添加
<% p ['@posts is', @posts] %>并在您的控制台上查看是否为 nil 吗? -
菲利普,谢谢你的建议;我到底在哪里插入这段代码?再次感谢。
-
就在您的
<div class="row">上方 -
很酷,谢谢...现在试试。
-
得到以下结果: ActionView::Template::Error ('nil' 不是 ActiveModel 兼容的对象。它必须实现 :to_partial_path。): 2: 3: 4:5: 6:app/views /blog/posts/index.html.erb:5:in `_app_views_blog_posts_index_html_erb__299498262_61543404'
标签: ruby-on-rails