对于我的一种方法,以下方法无效。我几乎复制所有直接从官方文档的:红宝石/葡萄在一定条件下所需的参数
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
这是给在“给定”行一个错误。任何人都知道什么是错的。我的目标:仅当“authenticationType” ==“本地”应该向用户提供“管理员”和“密码”
错误:
[ 2017-03-03 00:39:18.4848 14970/7f5d0603f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /vagrant/masterapi: An error occurred while starting up the preloader. Error ID: 0bd79149 Error details saved to: /tmp/passenger-error-3OYsdJ.html Message from application: Grape::Exceptions::UnknownParameter (Grape::Exceptions::UnknownParameter)
/usr/local/lib/ruby/gems/2.3.0/gems/grape-0.16.2/lib/grape/dsl/parameters.rb:170:inblock in given'
each'
/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
block in '
你应该显示错误。 –