1
由於某些原因,fields_for未顯示我的嵌套屬性文本框。我已經遵循瞭如何讓它工作但仍然沒有運氣的指南。任何幫助將不勝感激。不適用於嵌套屬性欄的字段
*這個奇怪的部分是我曾使用Oracle作爲數據庫,然後我切換到Sqlserver,現在它不起作用。
這是我進入MODLE
class Entry < ActiveRecord::Base
include WorkorderTranslator
belongs_to :release
belongs_to :session
belongs_to :sheet
has_many :stm_entries, :dependent => :destroy
attr_protected :id
accepts_nested_attributes_for :stm_entries
class StmEntry < ActiveRecord::Base
self.primary_key = 'id'
belongs_to :entry
attr_protected :id
這是我的看法
-if current.stm?
-e.stm_entries.each do |stm|
%tr{:id => (stm.editable == true ? 'target' : '') }
%td.b.trace-table= e.trace_number
=render "heat_form", :entry => e, :f => f
-if stm.editable == true
=f.simple_fields_for :stm_entries, stm do |ff|
%td.b.trace-table{:style => 'padding-top:3px;'}
= ff.input :date, :as => :string, :readonly => true, :input_html => {:style => 'width:90%;', :value => (ff.object.date.nil? ? Date.today.strftime("%m/%d/%Y") : ff.object.date.strftime("%m/%d/%Y")), :placeholder => 'Date', :class => 'floatlabel'}, :label => false
%td.b.trace-table{:style => 'padding-top:3px;'}
= ff.input :user, :readonly => true, :input_html => {:style => 'width:90%;', :placeholder => 'User ID', :class => 'floatlabel'}, :label => false
%td.b.trace-table{:style => 'padding-top:3px;'}
= ff.input :splices, :label => false, :input_html => {:style => 'width:90%;', :placeholder => 'Splices', :class => 'floatlabel'}
什麼是stm?你能否在你的問題中顯示這個表格的其餘部分 – David
我將我的其餘部分添加到原始問題@David – Snowman08