Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

try

<% @users.each do |user| %>
  ...
<% end %>

and be sure that @users isnt nil.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top