ruby-on-rails – 显示活动管理员中的错误消息有许多关系表
发布时间:2020-12-16 20:22:09 所属栏目:百科 来源:网络整理
导读:我正在面临一个问题,显示活动管理员中的错误消息. 我收到窗体中显示的所有错误消息. 但是在下面的代码中,我需要至少一个技能,最多可以添加5个技能. 否则需要抛出一个错误信息. 我在模型中添加了一个验证: 验证:技能,:length = {:minimum = 1,:maximum =
我正在面临一个问题,显示活动管理员中的错误消息.
我收到窗体中显示的所有错误消息. 我在模型中添加了一个验证: 验证:技能,:length => {:minimum => 1,:maximum => 5, 这样可以完美验证,但不会显示任何错误信息. 任何人都可以帮助我显示错误信息. 以下是代码: form :html => { :enctype => "multipart/form-data" } do |f| f.inputs "User",:multipart => true do f.input :name f.input :email,:as => :email f.input :profile_name f.input :date_of_birth f.input :gender,:as => :select,:collection => Gender::GENDERS end f.inputs "Skills* ( minimum 1 & maximum 5 )" do f.has_many :skills do |p| if !p.object.nil? # show the destroy checkbox only if it is an existing appointment # else,there's already dynamic JS to add / remove new appointments p.input :_destroy,:as => :boolean,:label => "Destroy?",:hint => "Check this checkbox,if you want to delete this field." end p.input :description p.input :title end end end end 解决方法
activeadmin 0.5.1在github上可用.
它包含更改日志中的下一行
这里是拉这个功能的请求 例 form do |f| f.semantic_errors *f.object.errors.keys f.inputs f.inputs "Locations" do f.has_many :locations do |loc| loc.input :address loc.input :_destroy,:label => "Delete" end end f.buttons end 使用它添加到Gemfile gem 'activeadmin',:git => "git://github.com/gregbell/active_admin.git",:tag => "v0.5.1" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |