打印

ruby下拉列表出问题,该如何实现?

ruby下拉列表出问题,该如何实现?

我从一个kinds表中取类型名称来对article归类,以kin_id字段在articles表中存储,但出现如下问题:

Showing app/views/articleadmin/_form.rhtml where line #8 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.inject

Extracted source (around line #8):

5: <%= text_field 'article', 'title'  %></p>
6:
7: <p><label for="kind_name">分类</label><br/>
8: <select name="kin_id"><%= options_from_collection_for_select(@kinds,'id','name')%></select></p>
9:
10: <p><label for="article_content">内容</label><br/>
11: <%= text_area 'article', 'content','cols'=>40,'rows'=>8  %></p>

该如何解决?
完完整整的下拉列表又该是如何做的?
希望达人帮忙一下!!!

TOP

引用:
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.inject
@kinds是不是为nil?
First they ignore you, then they laugh at you, then they fight you, then you win.

TOP

刚接触,还在一知半解中

问题已解决,谢谢...

TOP

楼主是如何解决的?
我也出现了2楼的问题。

TOP