jqGrid错误与Ruby on Rails
我遵循本指南http://www.2dconcept.com/jquery-grid-rails-plugin,设置示例jQuery数据网格。jqGrid错误与Ruby on Rails
一切似乎都很好,但是当我去http://127.0.0.1:3000/users,我得到这个:
NoMethodError in Users#index
Showing users/index.html.erb where line #12 raised:
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
Extracted source (around line #12):
9: <th>Role</th>
10: </tr>
11:
12: <% for user in @users %>
13: <tr>
14: <td><%=h user.pseudo %></td>
15: <td><%=h user.firstname %></td>
任何想法,我做错了什么?
我还没有使用jqGrid,但示例代码是设置users
并且您正在访问@users
- 我不确定这是否是您的部分或教程中的错误。
尝试
<% @users.each do |user| %>
...
<% end %>
,并确保@users心不是零。
我很确定@users不是零,但仍然没有运气。 – NoahD 2009-09-17 16:45:20
请给我看你的控制器代码和所有的视图代码.. – Lichtamberg 2009-09-18 07:37:09
我已经用Rails 4.0创建了示例应用程序jqgrid,请看看它。
希望大家能够喜欢这一点,看看下面的链接 -
https://github.com/Rameshwar007/jqgrid_rails_4_sample
感谢
我认为这是正确的语法通过在@users每个用户去了? – NoahD 2009-09-16 23:37:26
我认为你的@users是零 - 在演示中他设置'users'而不是'@ users' – 2009-09-16 23:44:17
如果我从@users - >用户切换,我会为# –
NoahD
2009-09-17 00:06:48