Insomania Insomania - 1 year ago 111
Ruby Question

Validation Error in Active Admin in Ruby On Rails 5

Hi i am trying to add validation in Active Admin model, and doing it as follow:

ActiveAdmin.register Skill do

permit_params :title, :text, :status
validates :title, length: { maximum: 20 }, presence: true


and it gives following error:

undefined method `validates' for # ActiveAdmin::ResourceDSL:0x007f576cab00c0

when i use same thing on frontend model then it works fine, don't know what's going on,

Please help me to find out the issue.

Answer Source

Try to add validation in the Active record model instead in the active admin.


validates :title, length: { maximum: 20 }, presence: true

in the Skill model

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download