Hm.. saat Review#create isi @categories didapat dari mana y?
erorny bukan d validates_presence_of. trus sekedar saran itu baris 14 ke bawah
bisa menggunana select, atau select_tag.

2008/6/26 Dwi Wijonarko <[EMAIL PROTECTED]>:
> Saya membuat 2 tabel yaitu reviews dan categories, dengan hubungan category
> has_many reviews.
> Yang jadi masalah adalah ketika saat mengisi review, ketika tidak diisi
> apa-apa (kosong), menjadi error sebagai berikut:
>
> NoMethodError in Review#create
>
> Showing app/views/review/_form.rhtml where line #15 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 #15):
>
> 12:
> 13: <p><label for="review_category_name">Category<br/>
> 14: <select name="category">
> 15: <% @categories.each do |category| %>
> 16: <option value="<%= category.id %>">
> 17: <%= category.name %>
> 18: </option>
>
> padahal pada review.rb sudah seperti berikut :
> class Review < ActiveRecord::Base
> validates_presence_of :title, :body_text, :status, category_id
> belongs_to:category
> end
>
> Kenapa ya? Ketika baris 12 -18 dihilangkan baru muncul keterangan kosongnya
> (validates_of_presence baru berfungsi).
> Tapi tidak bisa menggunakan combo box ya?
> Maaf kalo pertanyaannya kurang berbobot.
>
> [Non-text portions of this message have been removed]
>
> 



-- 
Fadhil Mandaga

PT Jerbee Indonesia
www.jerbee.co.id

Jl. Palapa No. 27 Kompleks Telkom
Kebonkopi - Cimahi Bandung 40535
Jawa Barat - Indonesia

Phone: +62 22 60 197 39
Cell: +62 815 700 53 96
Email:
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Kirim email ke