Reputation: 8302
I'm following this guide, http://www.2dconcept.com/jquery-grid-rails-plugin, to setup a sample jQuery datagrid.
Everything appears to be good, but when I go to http://127.0.0.1:3000/users, I get this:
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>
Any ideas as to what I am doing wrong?
Upvotes: 0
Views: 912
Reputation: 2759
I have created sample application jqgrid with Rails 4.0, take a look at it.
Hope you will enjoy this, find below link -
https://github.com/Rameshwar007/jqgrid_rails_4_sample
thanks
Upvotes: 0
Reputation: 11821
try
<% @users.each do |user| %>
...
<% end %>
and be sure that @users isnt nil.
Upvotes: 0
Reputation: 31761
I haven't used jqGrid, but the sample code is setting users
and you're accessing @users
- I'm not sure if that's an error on your part or the tutorial.
Upvotes: 1