0
是否可以創建這種類型的顯示錯誤像一個簡單的模型? http://i.imgur.com/8t6ef.pngRails3:在多模式表單中顯示驗證錯誤?
我得到創建兩個模型...但如果我填寫不正確的形式..錯誤消息不會出現和錯誤Rails屏幕說我,例如,「驗證失敗:field1不能爲空......」
型號:
class Step < ActiveRecord::Base
#validates
validates :tree_id, :presence => true, :numericality => true
validates :is_first, :presence => true, :length => {:maximum => 1}
validates :status, :presence => true, :numericality => true
validates :step_type_id, :presence => true
#relations
belongs_to :step_type
belongs_to :tree
has_many :statements
accepts_nested_attributes_for :statements
end
class Statement < ActiveRecord::Base
#validates
validates :step_id, :presence => true, :numericality => true
validates :title, :presence => true, :length => {:maximum => 255}
validates :statement, :presence => true
validates :help, :presence => true
validates :is_last_version, :presence => true, :length => {:maximum => 1}
#relations
belongs_to :step
has_many :transitions
end
任何例子或者建議?
你在'steps_controller.rb'(約59行)有什麼? – Baldrick
對不起,我解釋了這個問題很糟糕,我嘗試在嵌套表單中查找信息。謝謝! – user1364684