带有项数组的Rails 5.1的to_hash和strong_parameters

时间:2017-05-12 22:37:42

标签: ruby-on-rails ruby-on-rails-5 strong-parameters

我有以下参数声明:

protocol TestProt {
    init()
    func testMe() -> String
}

class Factory {

    static public func getObject<T: TestProt>() -> T {
        return T();
    }
}

let object: MyObject = Factory.getObject()
let object: override_MyObject = Factory.getObject()

但收到以下错误:

  

方法to_hash已弃用,将在Rails 5.1中删除,如    def line_item_params params.require(:line_items).map do |p| ActionController::Parameters.new(p.to_hash).permit(:quantity, :price, :menu_item_id) end end 不再继承哈希值。运用   这种弃用的行为暴露了潜在的安全问题。如果你   继续使用此方法您可能正在创建安全性   您的应用中可以利用的漏洞。相反,考虑一下   使用其中一个未弃用的文档化方法:   http://api.rubyonrails.org/v5.0.1/classes/ActionController/Parameters.html

我只是发布一系列项目。应如何处理?

1 个答案:

答案 0 :(得分:1)

8151 [main] WARN org.apache.hadoop.mapred.YarnChild - Exception running child : org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: Found unrecoverable error [10.74.51.71:9200] returned Not Found(404) - [TypeMissingException[[test_2017051222] type[[vehicle, trying to auto create mapping, but dynamic mapping is disabled]] missing]]; Bailing out..
    at org.elasticsearch.hadoop.rest.RestClient.retryFailedEntries(RestClient.java:207)
    at org.elasticsearch.hadoop.rest.RestClient.bulk(RestClient.java:170)
    at org.elasticsearch.hadoop.rest.RestRepository.tryFlush(RestRepository.java:225)
    at org.elasticsearch.hadoop.rest.RestRepository.flush(RestRepository.java:248)
    at org.elasticsearch.hadoop.rest.RestRepository.doWriteToIndex(RestRepository.java:187)
    at org.elasticsearch.hadoop.rest.RestRepository.writeToIndex(RestRepository.java:163)
    at org.elasticsearch.hadoop.mr.EsOutputFormat$EsRecordWriter.write(EsOutputFormat.java:151)
    at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:566)
    at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
    at org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer$Context.write(WrappedReducer.java:105)
    at org.apache.hadoop.mapreduce.Reducer.reduce(Reducer.java:150)
    at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171)
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:635)
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:390)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

您可以通过将哈希选项传递给 "settings": { "number_of_shards": 5, "number_of_replicas": 1, "index.query.default_field":"test", "index.refresh_interval" : "5s", "index.mapper.dynamic": false , "analysis": { "filter": { "ngram_filter": { "type": "ngram", "min_gram": 2, "max_gram": 18, "token_chars": [ "letter", "digit" ] } }, "analyzer": { "ngram_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "ngram_filter" ] } } } } 并使用包含嵌套对象白名单键的数组来将对象数组列入白名单。