Domanda

Sto seguendo questa guida, http://www.2dconcept.com/ jquery-grid-rails-plugin , per configurare un datagrid jQuery di esempio.

Tutto sembra essere buono, ma quando vado a http://127.0.0.1:3000/users , ottengo questo:

 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>

Qualche idea su cosa sto facendo di sbagliato?

È stato utile?

Soluzione

Non ho usato jqGrid, ma il codice di esempio sta impostando utenti e stai accedendo a @users - Non sono sicuro che si tratti di un errore sul tuo parte o tutorial.

Altri suggerimenti

try

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

e assicurati che @users non sia zero.

Ho creato l'applicazione di esempio jqgrid con Rails 4.0, date un'occhiata.

Spero che ti piacerà, trova sotto il link -

https://github.com/Rameshwar007/jqgrid_rails_4_sample

grazie

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top