我在user.html.haml
和apps_controller
模型之外的视图(App
)中有以下内容:
#myModal.modal.hide.fade{"aria-hidden" => "true", "aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"}
.modal-header
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
%h3#myModalLabel Add Mobile App
= form_for @app, class: 'modal-body' do |f|
= f.label :name, class: 'pull-left'
= f.text_field :name, style: 'width: 500px;'
.modal-footer
%button.btn{"aria-hidden" => "true", "data-dismiss" => "modal"} Close
= f.submit "Save App", class: "btn btn-primary"
这当前成功地将数据保存到App
模型中,但它没有触发我在App
模型中的验证。
在与模型不同的视图中生成记录时,验证是否有效的原因是什么?