# Showing error messages in active admin for has many relationship

**URL:** <https://www.ruby-forum.com/t/showing-error-messages-in-active-admin-for-has-many-relationship/224533>\
**Category:** Rails\
**Created:** [November 15, 2012, 11:46am UTC](https://www.ruby-forum.com/t/showing-error-messages-in-active-admin-for-has-many-relationship/224533 "2012-11-15T11:46:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 15, 2012, 11:46am UTC](https://www.ruby-forum.com/t/showing-error-messages-in-active-admin-for-has-many-relationship/224533/1 "2012-11-15T11:46:32Z")

</div>

I am facing an issue showing up the error messages in active admin.

I get all the error messages displayed with the fields in the form. But  
in  
the code below, I need atleast one skill and maximum 5 skills to be  
added.  
Else need to throw an error message.

I’ve added a validation in model as :

validates :skills, :length =\> { :minimum =\> 1, :maximum =\> 5, :message  
=\> "  
should be atleast 1 and less than 5"}

This validates perfectly, but no error message is displayed.

Can anyone help me with the display of the error message.

Following is the code :

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  
endend

end
