rack

Rails 5 GET request nested array parameter changes unexpectedly

被刻印的时光 ゝ 提交于 2020-04-17 19:06:00
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

Rails 5 GET request nested array parameter changes unexpectedly

怎甘沉沦 提交于 2020-04-17 19:05:23
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

Rails 5 GET request nested array parameter changes unexpectedly

*爱你&永不变心* 提交于 2020-04-17 19:05:18
问题 I have upgraded a Rails 4 application to Rails 5 (5.2.4.1 to be exact). I have a GET endpoint in my code with an rspec test. The test code sends the request as: get :fetch, params: { id: 123, logs: [[1, 2, :weekly], [1, 4, :mothly]] } When the controller receives the request, params['logs'] contains [["1"], ["2"], ["weekly"], ["1"], ["4"], ["monthly"]] This is different from what I expected, which is [["1", "2", "weekly"], ["1", "4", "monthly"]] The incoming URL contains (after decoding the

【7.1.1】ELK集群搭建 之 ES集群

隐身守侯 提交于 2020-04-13 22:22:44
【今日推荐】:为什么一到面试就懵逼!>>> 写在前边 昨天晚上就已经完成这篇博客了,就是在测试这块是否正常跑起来,晚上没搞完,上班前把电脑关机带着,结果没保存!基本上昨天写的东西都丢了,好在博客园的图片url还在。 为了让大家都轻松些,我轻松写,你轻松看。打算把文章的篇幅缩小,拆分成多个部分,这样更新频率会提高,写起来看起来也不会那么累,也不会再出现一次性丢那么多稿的问题…… 本文记述Elasticsearch集群部分,下边会有说明具体的结构 部署架构 整体图 本文部分结构图 node 1~3为集群的数据节点,同时竞争master,tribe-node为部落节点,负责Logstash与Kibana的连接 好处是无需指明master节点,不用多启动一个只负责协调的节点,减少资源浪费。 环境准备 GNU/Debian Stretch 9.9 linux-4.19 elasticsearch-7.1.1-linux-x86_64.tar.gz 本文为了模拟,使用Docker的centos7,文中不会出现Docker操作部分,与正常主机无异 开始搭建 1.root权限编辑/etc/security/limits.conf sudo vim /etc/security/limits.conf 添加如下内容: * soft memlock unlimited * hard memlock

Adding 'SameSite=None;' cookies to Rails via Rack middleware?

别等时光非礼了梦想. 提交于 2020-04-13 03:59:49
问题 On February 4th 2020, Google Chrome will require SameSite=None; to be added to all cross-site cookies. Rails 6.1 and soon Rails 6.0 have added a same_site: :none option to the rails cookie hash: cookies["foo"]= { value: "bar", expires: 1.year.from_now, same_site: :none } But older Rails 5.x apps won't receive the upgrade to have access to the same_site options hash. I know the SameSite=None; cookie option can be manually added to Rails in a controller using: response.headers["Set-Cookie"] =

How to set port for Rack app?

邮差的信 提交于 2020-04-10 03:27:05
问题 builder.rb: def app Rack::Builder.new do run App.new end.to_app end How to run on a given port? 回答1: Try: Rack::Handler.default.run(app, :Port => 3000) Although it would be more typical to run your app in a config.ru file and specify port as a command line option to rackup , e.g.: rackup -p 3000 . 回答2: When you rackup just specify it with option -p so: rackup -p 8808 would work just fine. 来源: https://stackoverflow.com/questions/32594945/how-to-set-port-for-rack-app

分布式存储原理:ElasticSearch

安稳与你 提交于 2020-03-18 21:53:44
3 月,跳不动了?>>> 对于一个分布式存储系统来说, 数据是分散存储在多个节点上的 。如何让数据 均衡 的分布在不同节点上,来保证其高可用性? 所谓均衡,是指系统中每个节点的负载是均匀的,并且在发现有不均匀的情况或者有节点增加/删除时,能及时进行调整,保持均匀状态 。本文将探讨Elasticsearch的数据分布方法,文中所述的背景是Elasticsearch 5.5。   在Elasticsearch中,以Shard为最小的数据分配/迁移单位。数据到节点的映射分离为两层:一层是数据到Shard的映射(Route),另一层是Shard到节点的映射(Allocate)。   一方面,插入一条数据时, ES会根据指定的Key来计算应该落到哪个Shard上 。默认Key是自动分配的id,可以自定义,比如在我们的业务中采用CompanyID作为Key。 因为Primary Shard的个数是不允许改变的,所以同一个Key每次算出来的Shard是一样的,从而保证了准确定位 。 shard_num = hash(_routing) % num_primary_shards   另一方面,Master会为每个Shard分配相应的Data节点进行存储,并维护相关元信息。 1、通过Route计算出来的Shard序号,2、在元信息中找到对应的存储节点,便可完成数据分布 。Shard

“Error bad URI” when trying to get WEBrick to accept HTTPS

久未见 提交于 2020-02-28 05:18:23
问题 So I've got a simple Sinatra site: # app.rb require 'sinatra' get '/' do 'Hello world!' end And I can set up rack to serve it over HTTP: # config.ru require './app' run Sinatra::Application # vim: ft=ruby And it works fine when I browse to http://localhost:9292 : % rackup [2013-01-22 10:27:52] INFO WEBrick 1.3.1 [2013-01-22 10:27:52] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.4] [2013-01-22 10:27:52] INFO WEBrick::HTTPServer#start: pid=7525 port=9292 127.0.0.1 - - [22/Jan/2013 10:28:05]

调试 ambari-server 总结

爱⌒轻易说出口 提交于 2020-02-27 15:36:27
刚开始debug ambari-server的时候,很多逻辑都是第一次接触。其中有很多知识点还是记录一下的好,做个备忘。这些知识点对于自定义api的开发还是很有作用的。 1. api的子href的最后一个字符串如何定义?例如,指定一个id? 解答: ambari 2.6 编辑key_properties.json,将当前资源类型与含有id的value相映射。 举例: <!--more--> ambari 2.7 路径:org/apache/ambari/server/controller/internal/RackResourceProvider.java public static final String RACK_ID_PROPERTY_ID = PropertyHelper.getPropertyId("rack", "rack_id"); public static final String RACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("rack", "rack_name"); public static final String RACK_HEIGHT_PROPERTY_ID = PropertyHelper.getPropertyId("rack", "rack_height"); public

For a rack app, how do I make passenger-standalone serve the output of .erb files rather of sending the .erb file itself?

霸气de小男生 提交于 2020-01-17 09:28:32
问题 I have a simple config.ru rack app where I only require and run rack-server-pages to provide dynamic pages in a quick and convenient way. This config.ru app is served by phusion passenger-standalone (which uses nginx internally). .erb files are processed and served correctly, except when I explicitely add the .erb extension to a URL (for a .erb file). In that case the server will send me the .erb file for download, rather than its output. Obviously I would like to avoid that. To make it