编辑 ActiveAdmin 验证
只需设置 ActiveAdmin 就没有任何实际问题,但是当我进入任何编辑/创建表单时,我遇到一个小问题:
我的用户有一个名为“shortcut_url”的属性,它仅定义用户页面的路径,即示例。 com/userjohn 其中 userjohn 是快捷方式 url。 Activeadmin 将该属性识别为 URL,并且不允许我创建用户来验证“userjohn”不是有效的 URL。我赞扬 ActiveAdmin 足够聪明,能够捕获属性名称中的“url”,但在这种情况下,我宁愿不进行此验证。有谁知道我在哪里可以找到覆盖此验证的地方?我翻阅了文档,但无济于事......任何帮助将不胜感激!
Just set up ActiveAdmin without any real issues, but when I get to any edit/create forms, I get a small issue:
I have an attribute for my users called "shortcut_url" which defines only the path to the users' page i.e. example.com/userjohn where userjohn would be the shortcut url. Activeadmin recognizes the attribute as a URL and won't let me create a user validating that "userjohn" is nopt a valid URL. I commend ActiveAdmin for being smart enough to catch "url" in the attribute name, but in this case, I'd rather not have this validation. Does anyone know where I can find a place to override this validation? I poked through the documentation, but to no avail... Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为它实际上决定了输入类型。要覆盖验证,您只需更改输入类型。我遇到了一个名为“网站”的字段的问题(它一直说我的网址不允许)。
这是 app/admin/user.rb 的示例:
它实际上只是 active_admin 内置的一些样式。我确信他们对 type="url" 和 type="email" 进行了验证。可能有更好的方法(禁用样式表中的样式),但这会让您继续前进。
瑞安
I think it's actually formtastic which determines the input type. To override the validation you just need to change the input type. I had an issue with this with a field called "website" (it kept saying my url wasn't allowed).
Here's an example of app/admin/user.rb:
It's actually just some styles that come built in with active_admin. I know for sure they have validations on type="url" and type="email". There's probably a better way around it (disabling the style in the stylesheets) but this will get you going.
Ryan