小编Rya*_*Mes的帖子

为什么respond_with被从rails 4.2中移除到它自己的gem中?

rails 4.2中, respond_with已从核心移出到响应者gem中.

Beta发行说明.

respond_with has moved out and into its own proper home with the responders gem.

有人可以解释一下原因吗?什么使响应者宝石成为适当的家?它留在Rails宝石有什么问题?

ruby ruby-on-rails

41
推荐指数
1
解决办法
2万
查看次数

发送或接收电子邮件时发送webhook

我一直在寻找如何创建在Gmail中发送或接收电子邮件时触发的webhook.例如,有人发送电子邮件,该电子邮件作为JSON对象被POST为我的一个应用程序.我发现很多中间人应用程序/服务都是这样做的(zapier提供了我想要的所有功能,但它需要花钱),但是我找不到任何关于如何自己实际执行此操作的文档,所以我不需要付费它.

这可能吗?

integration gmail webhooks

22
推荐指数
2
解决办法
2万
查看次数

为什么模块`ClassMethods`在同一名称空间中定义和扩展?

我试图理解来自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)

ruby gem

18
推荐指数
1
解决办法
4887
查看次数

在graphql架构中连接中有边和节点的原因是什么?

我试图了解更复杂的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字段,因为你可以从边缘获得相同的数据?这只是为了方便吗?

facebook relay graphql

11
推荐指数
2
解决办法
1933
查看次数

ActiveJob是否具有特定优先级的队列?

看看下面的工作,我会假设工作在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中找到它.

ruby ruby-on-rails rails-activejob

10
推荐指数
1
解决办法
2887
查看次数

活动作业抛出意外错误

我想让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)

ruby-on-rails delayed-job rails-activejob

8
推荐指数
1
解决办法
437
查看次数

无法弄清楚为什么要更新子网

我正在使用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)

amazon-web-services ansible

8
推荐指数
1
解决办法
68
查看次数

枚举选项"新"不起作用

我试图在我的模型上创建一个枚举,我希望其中一个状态是"新的"

例如

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)

我理解为什么会这样,但我想知道是否有办法解决这个问题?

enums ruby-on-rails-4

7
推荐指数
1
解决办法
2848
查看次数

lambda + efs - 安装与接入点

我尝试将 aws lambda 和 efs 一起使用,这样我就可以执行超过默认 lambda 存储限制 500mb 的操作。我很困惑Local mount pathAccess 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 中使用哪一条?

amazon-web-services aws-lambda amazon-efs

7
推荐指数
1
解决办法
4211
查看次数

如何在 cloudwatch 中将 2 个搜索指标与数学表达式结合起来?

我试图获取运行 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)

metrics amazon-web-services amazon-cloudwatch

6
推荐指数
1
解决办法
9027
查看次数