문제

이 안내서를 따르고 있습니다. http://www.2dconcept.com/jquery-grid-rails-plugin, 샘플 jQuery datagrid를 설정하려면.

모든 것이 좋은 것처럼 보이지만 내가 갈 때 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가 nil이 아닌지 확인하십시오.

Rails 4.0으로 샘플 응용 프로그램 JQGrid를 만들었습니다.

당신이 이것을 즐기시기를 바랍니다. 아래 링크를 찾으십시오 -

https://github.com/rameshwar007/jqgrid_rails_4_sample

감사해요

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top