我有一个HBase表(部分)利用十六进制字节来构造其rowkeys.我可以从Hbase Shell查询,如下所示
get 'my_table', "XYZ:\x7F\xFF\xFF\xFF\xFF\xFF\xFF\x82"
Run Code Online (Sandbox Code Playgroud)
但是,我想使用stargate API(或作为包装器的众多ruby gem之一)远程查询hbase.
如果我运行上面完全相同的查询,我找不到404.请注意,:
和\
字符是URL编码的.
curl "http://myHbaseServer.domain:8080/my_table/XYZ%3A%5Cx7F%5CxFF%5CxFF%5CxFF%5CxFF%5CxFF%5CxFF%5Cx82/content:raw"
=> 404 Not Found
Run Code Online (Sandbox Code Playgroud)
我知道这种格式是正确的,因为它只是在调用/
端点时返回一个表列表.它也没有引发连接错误.有关这些角色是否被正确转义的任何想法?
谢谢!
我是刚接触Puma的新手,以前曾与Unicorn合作。
Unicorn配置使用before_fork
and after_fork
方法来断开连接,然后在派生后重新建立连接。
但是,Puma没有。它仅具有on_worker_boot
在概念上与该after_fork
方法相似的方法。
彪马(Puma)是否也利用工人流程的分支?像独角兽一样在分叉之前不需要断开连接吗?
谢谢!
before_fork do |server, worker|
# other settings
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
end
after_fork do |server, worker|
# other settings
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
end
end
Run Code Online (Sandbox Code Playgroud)
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
Run Code Online (Sandbox Code Playgroud) 我有以下设置,其中我的一个类包含一个位于另一个文件中的模块
要注意的关键一点是,模块MyBar
确实不是生活在一个类似名称的文件。它住在里面my_foo.rb
。
module MyBar
def self.test
"This is a test string"
end
end
Run Code Online (Sandbox Code Playgroud)
require 'my_foo'
class SomeClass
include MyBar
def initialize
puts MyBar.test
end
end
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到一个 NameError
NameError - uninitialized constant MyBar
Run Code Online (Sandbox Code Playgroud)
看起来 Rails 正试图变得聪明,并假设因为模块名称是MyBar
它应该位于一个类似命名的文件中my_bar.rb
。
我尝试通过将名称更改为它期望的名称来测试这个理论,它突然正常工作
my_foo.rb (renamed)-> my_bar.rb
Run Code Online (Sandbox Code Playgroud)
问题是
Rails 为什么要这样做?好像假设太多了。我知道它是“约定优于配置”,但有几个有效的理由使文件名与模块名不匹配。
如何覆盖此行为?
每当我遇到 Postgres 错误时,它都会转储类似这样的内容
[4] pry(#<RSpec::ExampleGroups::CreateNewMatchesJob::MultiTenantNamespacing>)> User.all.each { |user| BreakerScoresJob.new.perform(user.id) }
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "identities"
LINE 1: ...ies".* FROM "excelon_auth_identities" WHERE "identitie...
^
: SELECT "excelon_auth_identities".* FROM "excelon_auth_identities" WHERE "identities"."external_identity_type" = $1 AND "excelon_auth_identities"."id" IN (2)
from /Users/jeeves/.rvm/gems/ruby-2.2.2@gb/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:641:in `prepare'
Run Code Online (Sandbox Code Playgroud)
这是一种非常困难的格式,因为查询总是被切断,而且我希望看到它正在执行的完整查询,这样我就可以更好地了解它遇到的哪一行。
有什么办法可以查看整个查询吗?
谢谢!
我有一个非常基本的注释表单,它从用户那里获取一些文本输入,并POST
通过AJAX 发送请求以创建新注释.
var CommentForm = React.createClass({
propTypes: {
// ...
// ...
},
handleFormSubmit: function(e) {
e.preventDefault();
var component = this;
return $.ajax({
type: "POST",
url: this.props.someURL,
data: // ???? - Need to figure out how to serialize data here,
dataType: "json",
contentType: "application/json",
success: (function(response){ alert("SUCESS") }),
error: (function(){ alert("ERROR"); })
});
},
render: function() {
var component = this;
return (
<form onSubmit={component.handleFormSubmit} className="comments__form" id="new_comment" accept-charset="UTF-8">
// ...
</form>
);
}
});
Run Code Online (Sandbox Code Playgroud)
我需要序列化表单数据以便与我的POST
请求一起发送,但我不确定如何.我知道在JQuery中我可以选择表单元素并执行类似的操作$("#my_form").serialize() …
根据rails文档,使用submit_tag
助手将生成类似的内容
submit_tag\n# => <input name="commit" type="submit" value="Save changes" />\n
Run Code Online (Sandbox Code Playgroud)\n\n它包括财产name="commit"
为什么这会被包括在内?它是某种标准吗?尝试理解“提交”在这种情况下的含义
我注意到点击提交后它被包含在params
控制器内部。这是最近改变的吗?我认为只包含 url 参数和 POST/PUT 数据?
@参数
\n\n=> {“utf8”=>“\xe2\x9c\x93”,“authenticity_token”=>“4q3u+mfMi57YbchTAzaCI7WHmzfZJrLbTZ17aVwfq9uw8aMU1B3PBR13qfipgN6lbRoi0dywFU9i1AbJ0GP7UA==”,“电子邮件”=>“foo@example.co”, “密码”=>“(已编辑)", "dest"=>"", "commit"=>"登录", "controller"=>"sessions", "action"=>"log_in"}
谢谢!
\n我有一个使用 Postgres 的 Rails5 应用程序。当我推送新提交时,我正在尝试使用 Gitlab CI 来运行我的规范测试。
我尝试根据配置 .gitlab-ci.yml 文件和使用 postgres 服务的文档设置我的文件
我没有改变我的跑步者,所以它在运行 Gitlab 使用的任何默认设置。
services:
- postgres:9.6
variables:
POSTGRES_DB: galapagos_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: ""
before_script:
# System
- apt-get update -qq
# Ruby
- ruby -v
- which ruby
# Gems
- 'echo ''gem: --no-ri --no-rdoc'' > ~/.gemrc'
- gem install bundler
- bundle install --without production --jobs $(nproc) "${FLAGS[@]}"
# App
- RAILS_ENV=test bundle exec rake db:create
- RAILS_ENV=test bundle exec rake …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个基本的HTTP API和一些操作,比如POST /users
在数据库中创建一个新的用户记录.
我知道我可以模拟这些调用,但在某种程度上我想知道让我的Junit测试在真实(测试)数据库上运行是否更容易?这是一种不好的做法吗?是否只应对真实数据库进行集成测试?
我正在使用flyway来维护我的测试模式和maven以进行构建,因此我可以让它在每个构建中使用适当的模式重新创建测试数据库.但是我也担心在每次测试之间我需要一些额外的开销来维护/清理数据库的状态,我不确定是否有一个好的方法可以做到这一点.
我正在使用nginx,puma和capistrano部署我的Rails应用程序.它由一个被调用的用户deploy
部署,部署位置在主目录下(/home/deploy
)
我让Puma配置为在shared
Capistrano符号链接所有它发布到的文件夹下创建一个套接字.相应地,nginx也配置为查看该套接字(参见下面的配置文件)
但是,当我启动Rails/Puma网络服务器时 -
cd /home/deploy/my_app/current
SECRET_KEY_BASE=.... DATABASE_PASSWORD=... rails s -e production
Run Code Online (Sandbox Code Playgroud)
我注意到没有创建套接字文件.当我在浏览器中访问该站点然后查看Nginx错误日志时,它也抱怨该套接字不存在.
2016/07/17 14:26:19 [crit] 26055#26055: *12 connect() to unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: XX.YY.XX.YY, server: localhost, request: "GET http://testp4.pospr.waw.pl/testproxy.php HTTP/1.1", upstream: "http://unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock:/500.html", host: "testp4.pospr.waw.pl"
Run Code Online (Sandbox Code Playgroud)
如何让puma创建该套接字?
谢谢!
# config/puma.rb
...
# `shared_dir` is the symlinked `shared/` directory created
# by Capistrano - `/home/deploy/my_app/shared`
# Set up socket location
bind "unix://#{shared_dir}/tmp/sockets/puma.sock"
# Logging
stdout_redirect …
Run Code Online (Sandbox Code Playgroud) 我继承的 Postgres DB 中的一列的名称中有一个问号。
当我尝试选择它时,它会抛出错误
> select confirmed? from user_purchases;
ERROR: column "confirmed" does not exist
LINE 1: select confirmed? from user_purchases;
^
HINT: Perhaps you meant to reference the column "user_purchases.confirmed?".
Run Code Online (Sandbox Code Playgroud)
我还尝试使用反引号(“已确认?”)和引号(“已确认?”)选择它,但出现了相同的错误。
我该如何选择这个字段?
谢谢!