从外部视图触发创建时,验证不起作用

时间:2013-04-19 04:55:49

标签: ruby-on-rails haml

我在user.html.hamlapps_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模型中的验证。

在与模型不同的视图中生成记录时,验证是否有效的原因是什么?

0 个答案:

没有答案