在rails 4.2中, respond_with已从核心移出到响应者gem中.
Beta发行说明.
respond_with has moved out and into its own proper home with the responders gem.
有人可以解释一下原因吗?什么使响应者宝石成为适当的家?它留在Rails宝石有什么问题?
我一直在寻找如何创建在Gmail中发送或接收电子邮件时触发的webhook.例如,有人发送电子邮件,该电子邮件作为JSON对象被POST为我的一个应用程序.我发现很多中间人应用程序/服务都是这样做的(zapier提供了我想要的所有功能,但它需要花钱),但是我找不到任何关于如何自己实际执行此操作的文档,所以我不需要付费它.
这可能吗?
我试图理解来自github repo的代码.它是设置客户端的gem的主要模块.
module Github
# more code
class << self
def included(base)
base.extend ClassMethods # what would this be for?
end
def new(options = {}, &block)
Client.new(options, &block)
end
def method_missing(method_name, *args, &block)
if new.respond_to?(method_name)
new.send(method_name, *args, &block)
elsif configuration.respond_to?(method_name)
Github.configuration.send(method_name, *args, &block)
else
super
end
end
def respond_to?(method_name, include_private = false)
new.respond_to?(method_name, include_private) ||
configuration.respond_to?(method_name) ||
super(method_name, include_private)
end
end
module ClassMethods
def require_all(prefix, *libs)
libs.each do |lib|
require "#{File.join(prefix, lib)}"
end
end
# more methods ...
end …Run Code Online (Sandbox Code Playgroud) 我试图了解更复杂的graphql apis,它实现了Relay Cursor Connections Specification
如果你看一下我在github graphql api explorer上运行的查询
{
repository(owner: "getsmarter", name: "moodle-api") {
id
issues(first:2 ) {
edges {
node {
id
body
}
}
nodes {
body
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
totalCount
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意它有字段边和节点.
为什么github在api中有一个称为节点的附加字段?为什么他们不使用edge字段,因为你可以从边缘获得相同的数据?这只是为了方便吗?
看看下面的工作,我会假设工作在low_priority队列中运行.
class GuestsCleanupJob < ActiveJob::Base
queue_as :low_priority
#....
end
Run Code Online (Sandbox Code Playgroud)
我同意这一点,但这只是队列的名称正确吗?它实际上与优先级无关.例如,如果我创建了一个名为queue的作业,:my_queue那么它将被视为具有与:low_priority队列相同的优先级.
从文档中我无法找到任何表明我可以优先排队的工作.我知道delayed_jobs有这个功能,但我还没有在active_job中找到它.
我想让active_job与delayed_job一起工作.一切正常......因为代码按预期执行,但delayed_job条目报告存在错误.我得到的错误如下.
uninitialized constant ProcessEventJob
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/inflector/methods.rb:261:in `const_get'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/inflector/methods.rb:261:in `block in constantize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/inflector/methods.rb:259:in `each'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/inflector/methods.rb:259:in `inject'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/inflector/methods.rb:259:in `constantize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activesupport-4.2.1/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activejob-4.2.1/lib/active_job/core.rb:25:in `deserialize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activejob-4.2.1/lib/active_job/execution.rb:20:in `execute'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/activejob-4.2.1/lib/active_job/queue_adapters/delayed_job_adapter.rb:34:in `perform'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/backend/base.rb:94:in `block in invoke_job'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `call'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `call'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/backend/base.rb:91:in `invoke_job'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/worker.rb:204:in `block (2 levels) in run'
/home/getsmart/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:89:in `block in timeout'
/home/getsmart/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:99:in `call'
/home/getsmart/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:99:in `timeout'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/worker.rb:204:in `block in run'
/home/getsmart/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/worker.rb:203:in `run'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/worker.rb:280:in `block in reserve_and_run_one_job'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `call'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `call'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/home/getsmart/.rvm/gems/ruby-2.2.2@phoenix/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks' …Run Code Online (Sandbox Code Playgroud) 我正在使用Ansible在AWS中创建VPC.运行以下播放
- name: create vpc with multi-az subnets
ec2_vpc:
region: "{{ region }}"
cidr_block: "{{ vpc_cidr_block }}"
resource_tags: '{"Name":"{{ prefix }}_vpc"}'
subnets:
- cidr: "{{ vpc_cidr_subnet_public_0 }}"
az: "{{ region }}{{ availability_zone_0 }}"
resource_tags: '{"Name":"{{ prefix }}_subnet_public_0", "Class":"web", "Partner":prefix }'
- cidr: "{{ vpc_cidr_subnet_private_0 }}"
az: "{{ region }}{{ availability_zone_0 }}"
resource_tags: '{"Name":"{{ prefix }}_subnet_private_0", "Class":"db", "Partner":prefix }'
- cidr: "{{ vpc_cidr_subnet_private_1 }}"
az: "{{ region }}{{ availability_zone_1 }}"
resource_tags: '{"Name":"{{ prefix }}_subnet_private_1", "Class":"db", "Partner":prefix }'
internet_gateway: yes
route_tables:
- …Run Code Online (Sandbox Code Playgroud) 我试图在我的模型上创建一个枚举,我希望其中一个状态是"新的"
例如
enum status: { stale: 0, new: 1, converted: 2 }
Run Code Online (Sandbox Code Playgroud)
似乎rails拒绝这个以下错误.
You tried to define an enum named "status" on the model "Lead", but this will generate a class method "new", which is already defined by Active Record.
Run Code Online (Sandbox Code Playgroud)
我理解为什么会这样,但我想知道是否有办法解决这个问题?
我尝试将 aws lambda 和 efs 一起使用,这样我就可以执行超过默认 lambda 存储限制 500mb 的操作。我很困惑Local mount path和Access point之间的区别。
本地挂载路径是一个术语,用于描述文件系统在现有文件系统中的挂载位置,而访问点(也有自己的路径)是应用程序在代码中引用的位置?或者引用哪条路径实际上并不重要?
例如
AccessPointResource:
Type: 'AWS::EFS::AccessPoint'
Properties:
FileSystemId: !Ref FileSystemResource
PosixUser:
Uid: "1000"
Gid: "1000"
RootDirectory:
CreationInfo:
OwnerGid: "1000"
OwnerUid: "1000"
Permissions: "0777"
Path: "/myefs"
Run Code Online (Sandbox Code Playgroud)
这就是我创建接入点和直接在 lambda 上指定的安装路径以进行测试的方法。
我想我遇到的主要困惑是为什么有 2 条路径,它们之间有什么区别,以及我应该在 lambda 中使用哪一条?
我试图获取运行 lambda 时使用的内存百分比以显示在 cloudwatch 上的图表中。我知道还有其他方法可以提取数据,但由于本问题范围之外的原因,我想坚持使用搜索来提取指标。
我有下面的图表
{
"metrics": [
[ { "expression": "SEARCH('{SomeMetricNamespace} MetricName=\"MemorySize\"', 'Average', 300)", "id": "m1", "visible": "true" } ],
[ { "expression": "SEARCH('{SomeMetricNamespace} MetricName=\"MaxMemoryUsed\"', 'Average', 300)", "id": "m2", "visible": "true" } ],
[ { "expression": "m2/m1*100", "label": "pecentage memory used", "id": "e1", "stat": "Average" } ]
],
"view": "timeSeries",
"stacked": false,
"region": "us-west-2",
"stat": "Average",
"period": 300,
"title": "Memory",
"yAxis": {
"left": {
"label": "Percentage Usage",
"showUnits": false
}
},
"liveData": false
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误
Error in expression …Run Code Online (Sandbox Code Playgroud) ruby ×3
amazon-efs ×1
ansible ×1
aws-lambda ×1
delayed-job ×1
enums ×1
facebook ×1
gem ×1
gmail ×1
graphql ×1
integration ×1
metrics ×1
relay ×1
webhooks ×1