【发布时间】:2020-09-04 14:32:40
【问题描述】:
假设我们不想让用户名是banned = ['badWordOne', 'otherbadword', 'notthiseither']中的任何一个
我们如何做到这一点?
我尝试使用acceptance 并直观地将accept 更改为reject,但这不起作用:
banned_names = ['badWordOne', 'otherbadword', 'notthiseither']
validates :username, acceptance: { reject: banned_names }, if: :username
【问题讨论】:
标签: ruby-on-rails rails-models