对于我的一种方法,以下方法不起作用。我几乎直接从官方文档中复制了所有内容:
params do
requires :authenticationType, type: Array[String], values: ['LOCAL', 'AD']
given authenticationType: ->(val) { val == 'LOCAL' } do
requires :admin, type: String, allow_blank: false, regexp: /^[\w\.\@-]{1,64}$/
requires :password, type: String, allow_blank: false, regexp: /^[\w\.\@-]{1,64}$/
end
end
给出"给出的错误#34;线。任何人都知道什么是错的。我的目标:只有' authenticationType' ==' LOCAL'如果用户提供“管理员”#39;和密码'
错误:
[2017-03-03 00:39:18.4848 14970 / 7f5d0603f700 age / Cor / App / Implementation.cpp:304]:无法为其生成进程 application / vagrant / masterapi:启动时出错 预加载器。错误ID:0bd79149错误详细信息保存到: /tmp/passenger-error-3OYsdJ.html来自应用程序的消息: 葡萄::例外:: UnknownParameter (葡萄::例外:: UnknownParameter)
/usr/local/lib/ruby/gems/2.3.0/gems/grape-0.16.2/lib/grape/dsl/parameters.rb:170:inblock in given'
各'
/usr/local/lib/ruby/gems/2.3.0/gems/grape-0.16.2/lib/grape/dsl/parameters.rb:169:in
/usr/local/lib/ruby/gems/2.3.0/gems/grape-0.16.2/lib/grape/dsl/parameters.rb:169:ingiven' /vagrant/masterapi/controllers/papi_controller.rb:93:in
阻止'