好吧,這是我在rails中的第一個應用程序,所以希望這是一個簡單的問題。Rails表單助手失敗
這是我的目標:
- !ruby/object:ProductImage
attributes:
image_id:
product_id:
created_at:
updated_at:
attributes_cache: {}
這工作:
<%= image_form.text_field :product_id %>
但我得到了一個未定義的方法`image_id」爲:
<%= image_form.text_field :image_id %>
我只是不明白這一點...
Cheers for對此有任何幫助。
這是實際的部分:
<div class="image">
<% new_or_existing = product_image.new_record? ? 'new' : 'existing' %>
<% prefix = "product[#{new_or_existing}_product_image_attributes][]" %>
<% fields_for prefix, product_image do |i| -%>
<div class="input select">
<%= i.text_field :image_id %>
<%= link_to_function "remove", "$(this).up('.image').remove()" %>
</div>
<% end -%>
</div>
P.S文本字段被用來只是作爲一個例子
好吧,問題出在我的幫助器方法中,我使用的對象來自另一種方法,因爲我複製/粘貼它並沒有仔細檢查 – mynameisrufus 2010-01-30 03:40:16