大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 显示活动管理员中的错误消息有许多关系表,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我收到窗体中显示的所有错误消息.
但是在下面的代码中,我需要至少一个技能,最多可以添加5个技能.
否则需要抛出一个错误信息.
我在模型中添加了一个验证:
验证:技能,:length => {:minimum => 1,:maximum => 5,
:message => “应该是至少1和小于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 @R_88_6964@ end end end end
这里是拉这个功能的请求
https://github.com/gregbell/active_admin/pull/905
例
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"
以上是大佬教程为你收集整理的ruby-on-rails – 显示活动管理员中的错误消息有许多关系表全部内容,希望文章能够帮你解决ruby-on-rails – 显示活动管理员中的错误消息有许多关系表所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。