简体   繁体   中英

Validation Error in Active Admin in Ruby On Rails 5

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

end

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.

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

Add

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

in the Skill model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM