从不同的控制器渲染或重定向内容?
我是 Rails 新手,所以这是一个初学者问题。我想为一个具有不同控制器视图的应用程序创建一个管理页面 我尝试过
render 'projects/index'
,但它抛出的
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
重定向也没有太多运气(没有路由匹配),
最好的技术是什么?我有一种感觉,它一定非常简单,但我错过了一些东西
im new to rails so this is a beginner question. I want to make an admin page for an app with views from different controllers
I tried
render 'projects/index'
and it throws
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
also didnt have much luck with redirect_to (no routes match)
what is the best technique for doing that? I have a feeling it must be super simple and I'm missing something
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到的 nil 错误看起来像是视图的问题。您的视图可能使用未在控制器中初始化的数组。每个呈现管理视图的控制器都必须初始化视图中使用的数组。
也就是说,听起来您的视图应该只从一个控制器渲染。
The nil error that you're getting looks like a problem with the view. Your view may be using an array that wasn't initialized in your controller. Every controller rendering your admin view must initialize the arrays being used in your view.
That said, it sounds like your view should be rendered from only one controller.